I want to use the xib to setup a static UITableview.
How can do to get it?
I don't find the button to set tableView static or dynamic.
How about use the storyboard?
It isn't possible with xibs. If you want to use static cells in your UITableView, you'll have to use storyboard.
Go to tableView properties and change Content to Static Cells, look at this tutorial
Related
Have couple of questions
When I place a UITableViewController on the storyboard, and wish to work with static cells must I create a class deriving from UITableViewController or can I only create a class deriving from UITableViewCell for the custom cell?
I created a custom UITableViewCell placed number of controls on it and tried dragging with control pressed to create an outlet but couldn't, any ideas why?
If I wish each cell to have different controls and behavior can I set each cell a different custom UITableViewCell and if so how does the UITableViewController initialize it? do I need to load it programmatically?
1) The cell must be a subclass of UITableViewCell.
2) No, I don't know why that didn't work, it should. Where were you trying to make the connection to? The cell or the table view controller?
3) Yes, I think this is the best way to do it. Have a different custom cell class for each different kind of cell, and make IBOutlets from the custom cell to its controls. Then just make one IBOutlet from the table view controller to the cell itself (you can then refer to the controls with something like self.cellType1.label1 ...). You don't need to do anything to initialize the cells if they're made in the storyboard.
How can I change the selection / highlight color of a static UITableView? I understand for non-static UITableViews I might just subclass a UITableViewCell, but since I can't use cellForRowAtIndexPath with a static UITableView what should I do?
When using static cells from storyboard, you can customize each cell dynamically in tableView:willDisplayCell:forRowAtIndexPath:.
You can customise each cell in Interface Builder. You can set each cell's attributes by selecting it and then editing the appropriate fields in the attributes editors. For even more customised appearance/behaviour, you can even subclass a cell and let Interface Builder of its class in the identity inspector.
I've been wondering about UITableView's and their cells for a while. UITableView is a very handy UIView subclass, but there is a lot of predetermined/forced content on a UITableViewCell. I was wondering what is the best way to create a custom UIView (which will end up being a UITableViewCell) for UITableView?
The cell has a certain style that has to be set and there are predetermined UILabels and accessory views that are completely immutable, other than their contents. I find this to be a big waste, but just giving the cell a custom content view (and background view, if one pleases) doesn't prevent or remove these processes or restore the memory.
Is there any way to create a lighter version of a UITableViewCell subclass? Or is there a way to use a UIView with a selection method instead (other than essentially creating a custom UITableView using UIScrollView)?
Any suggestions would be really appreciated.
There are a few methods:
From a XIB file:
ios steps to create custom UITableViewCell with xib file
http://www.icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/
Using Drawing:
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007318 (4th and 5th examples)
There doesn't seem to be an answer for this. UITableViewCells will always have UILabels and other views automatically added to them. I'm not sure if they are allocated before you set them, though. They may have custom setting / allocation methods.
I need to make a cell having a larger length with no of sub views and i am having a no of these cells.i added all of these cells in UIScrollview,When I scroll scrollview I want that it load just like as UITableView Loaded. Please Suggest Some Method With Code.
Thanks In Advance.
You need not to use UIScrollView. I prefer having custom UITableViewCell which would be reused.
I have a .xib with an image and a label in the potition that i want..
And i want in the cellForRowAtIndexPath function to set image and label.text then to add then view in the cell and show the cell
Check this:
How do you load custom UITableViewCells from Xib files?
But i do not recommend to load UITableViewCells from xib.
You loose performance on a very critical part.
I recommend to create you UITableViewCell subclasses by code. Because inflating a XIB(XML) during scrolling will create buckings.
If you wan't to have a nice, snappy app, then code instead of XIB (at least the UITableViewCell subclasses).