I have created a custom .xib that contains a TableViewCell that contains a UIImageView And UILabel.
I want to know TableViewCell height in the .xib file, not to set it manually in heightForRowAtIndexPath function.
Also is there a property of UIImage to have the height of the TableViewCell when i change it by hand in the .xib file?
UITableViewCell is actually a UIView, so when you load it from xib the frame property can help you:
cell.frame.size.height
Related
I am trying to create a UITableViewCell that has both a label and a DisclosureIndicator displayed on the right of the cell, how would I go about this?
Just create your own custom UITableViewCell class and layout the UIButton and UILabel in the nib
I am creating UITableView cells dynamically and adding three labels on to it.I made my table as transparent by opaque no and clearcolor.
But the cells are being shown without spaces.I need to give space between cells.
Actually if i load a custom UITableViewCell from the xib file the space comes automatically. How to solve this issue?
UITableView with custom spacing
You can do this by cheating the tableView cell. By default you can only specify a single line, etched line or none so here is an alternative. You'll need to override the tableView delegate method:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Calculate your cell height with its contents, margin/padding/line width and return it. Set the background color of the cell to [UIColor clearColor] and make your table background the desired color for your separator. Subclass UITableViewCell and attach a backgroundContainerView and make it the desired background color for your cell. Attach all the subview to that backgroundContainerView.
Finally, in the UITableViewCell subclass implement
- (void)layoutSubviews
Here you should layout the subviews with the container view as if that is the whole cell.
In UITableView you have 2 properties : separatorStyle and separatorColor. Use them maybe your separator color is clearcolor so try and change it.
This problem is due to the difference in height in TableView and Custom cell. Set the cell height in heightForRowAtIndexPath delegate.
I have in the Interface builder a view which contain a UITableView and a custom UITableVIewCell, I would like to add an image view to my view. How I can do this? I have added an image view, but the cell of my table view have a strange color.
you need to make your cells and table view transparent
Add UIImageView to your XIB file and set its IBOutlet.
Now add UITableView to your XIB file on UIImageView and also set its IBOutlet..
Make UITableView's backgroundColor to clearcolor...
Hope this will work...
I have created my own UITableViewCell with XIB file. There's an UITextView inside. However, I don't know how to access its features and use its outlets with the UIViewController. What's the way to do it?
alt text http://cl.ly/a13e180c260e5e550b78/content
You can access it by pulling the subview out of the cell's subviews array and casting it to UITextView:
How you created your view hierarchy will determine the index to pass to objectAtIndex.
UITextView *textView = (UITextView*) [cell.subviews objectAtIndex:whateverIndex];
I have a UITableView with 3 sections inside of a UIViewController. Is it possible to have other controls above the UITableView for example a UISlider or a UIImage? If so, how can this be accomplished?
Note: These controls should not be in a UITableViewCell, they should be part of the view.
Yes, you can add a UIView to the table header or footer, see the tableHeaderView and tableFooterView properties. A UIView could be a UIControl or a view that contains UIControls.