With
StaticTableView
in ObjectiveC, you can manually create fixed content in table layout. This page will give you tutorial how to create this one.1Drag
ViewController
into the Storyboard.2Add
TableViewController
into storyboard next to ViewController
you added in previous step.3Add
ContainerView
into ViewController
you added in step 1.4You will see that container automatically generate sub view container. Delete it.
5Hold Ctrl key and click container. Then drag to table view controller like this
6Click "Embed".
the result will be like this
7Change Table View type to static and remove separator by setting property like image below
8To add row in table, drag Table View Cell to Table View.
9You can configure the number of sections, header, footer as you want.
10Configure each cell property.
11You can set custom high of each cell like this
12Right click the project -> "New file".
13Create class
MyStaticTableViewController
base class of UITableViewController
.14Setup the Table View Controller of storyboard to be the class
MyStaticTableViewController
.15Enable side-by-side code view by clicking button in the image below.
16Add
IBOulet
of object you want.17You can initialize controls in
ViewDidLoad
method like this18Delete the method
numberOfSectionInTableView
and numberOfRowsInSection
.19Build your code and try running it to see result.
What happens if I create very long static table view?
No problem. You can 2 finger scroll on the trackpad through a long static UITableView in a storyboard.Happy Coding!
No comments:
Post a Comment