iOS 8 Draw outside of UITableViewCell bounds - ios

thats simple I want my UILabel inside UITableViewCell draw outside of cell bounds to overlap tableHeaderView.
my tableViewView has only 1 row and tableHeaderView. I have not subclassed UITableViewCell
what I have done:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell.contentView.superview setClipsToBounds:NO];
[cell.contentView setClipsToBounds:NO];
[cell setClipsToBounds:NO];
}
but still cell clips its subview.
whats your idea?

#anhtu thanks for your hint. I just sent tableHeaderView to back which fixed the problem
[self.tableView sendSubviewToBack:self.tableView.tableHeaderView];

if you have only one cell and this label will appear only one time
put label outside the table view and put constrains for it

Related

Change the UIView height which is inside the UITableViewCell

I am trying to change the UIView height which is inside of the tableView. UIView height should not exceed the cell height.
i was trying to set the bounds of the view but it did not effect the view.
how can i fix this and change height of view
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
UIView *view=(UIView *)[cell viewWithTag:999];
view.backgroundColor=[UIColor redColor];
[view setBounds:CGRectMake(view.bounds.origin.x, view.bounds.origin.y, view.bounds.size.width, 400)];
return cell;
}
i found another way to do it. add a identifier to the view height constraints. and i can access it in controller like this.. link -> Is there a way to add an identifier to Auto Layout Constraints in Interface Builder?

Outlets cannot connected to repeating content in uitableview

I'm using Two tableview cells on single tableview like dis...enter image description here
and when I put subviews on both cells it is showing Outlets cannot connected to repeating content in uitableview
You can access the views with the help "tag". First set tag to the required view then access it as follows,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"tCell"];
//I have set CollectionView tag to 100 and Label tag to 50
UICollectionView *collect = (UICollectionView *) [cell viewWithTag:100]; //if the view is CollectionView
UILabel *lbl = (UILabel *) [cell viewWithTag:50]; //if it is a UILabel
return cell;
}

Add left and right margin to tableview of UITableViewController

I have tableview of UITableViewController with static cells.
Now I want to add left and right margin constrain at the runtime because I can not add constrain using Interface Builder.
Thanks
You could embed a UITableView inside a UIView instead of the UIViewController. If you did this you could resize the tableview and set margins in the interface builder. Create a new UIViewController (one that doesn't have a UITableView included) then drag a new UITableView onto it. Remember to set the data source and delegate to the new UIViewController. That should do it.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row==0){
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell" forIndexPath:indexPath];
cell.textLabel.text = #"your text";
return cell;
}
if(indexPath.row==1){
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell" forIndexPath:indexPath];
cell.textLabel.text = #"your text2";
return cell;
}
etc...
Not sure but May be - tableView's scrollview insets can help you-

Getting the actual UITableViewCell for a tapped UITableView created using the Storyboard.

I've created a UITableView in my application. I've Created a custom UITableViewCell called VideoCell which contains a UIWebview, a UIImageView and a UILabel.
The UIWebView is the same size as the UIImageView and in the same location, but behind the UIImageView. I want to hide the UILabel and the UIIMageView when I tap the cell, so that the UIWebView is revealed.
The VideoCell has a ReuseIdentifier set in the storyboard editor which I use for dequeing the VideoCell from in tableView:cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"VideoCell";
VideoCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
...
return cell;
}
How can I get a reference to the actual cell that I tap in tableView:didSelectRowAtIndexPath: in order to visibly change the properties?
I've tried just dequing with the same arguments
VideoCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Which returns me a VideoCell, but with no fields set up
I've also tried calling tableView:cellForRowAtIndexPath:
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
but that returns me a new instance of the VideoCell with the correct fields set up, and this is not the one that is currently displayed.
VideoCell *cell = (VideoCell*)[tableView cellForRowAtIndexPath:indexPath];
Don't call the data source method present in ViewController, call the method on actual instance of your UITableView
Try using this
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
instead of
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
cellForRowAtIndexPath:
is the correct way to get the instance of the cell. If you are unable to retrieve the exact cell you want in this way, it just means that your implementation in that method is wrong.

adding/removing a cell from grouped section in UITableView

I am trying to add/remove cells to my grouped table dynamically during runtime. This is my first app that I have ever made, and while I have tried many other people's suggestions, I am still not getting it to work. Here is my code that I am using:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
UILabel *lblName = (UILabel *)[cell viewWithTag:100];
[lblName setText:[intervalArray objectAtIndex:[indexPath row]]];
return cell;
You will need to update the array (will need to be an NSMutableArray) that is being used as the datasource for the UITableView. Then you can
[self.myTableView reloadData];
To reload the tableview
This is a good guide for dealing with updating TableView rows:
http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/ManageInsertDeleteRow/ManageInsertDeleteRow.html

Resources