UITableViewController is easy to create, but hard to change. It cannot add any additional view, such as toolbar or Google AdMob view. It is best practice to not use UITableViewController at all from the very beginning.
For existing UITableViewController, the below steps can be used to convert it to UIViewController with a UITableView
1. open storyboard, and add a new UIViewController,
2. select the old tableview object, and press option button and drag-drop it to the new viewcontroller. This will copy the tableview to the new UIViewController
3. Optionally, if the new UIViewController belongs to a navigation controller, then after creating the segua, then add a navigation item to the new UIViewController to customize the viewcontroller title, and then add bar button item to customize the left and right navigation bar button item
4. In the original uitableviewcontroller source file, in the class definition,
replace
UITableViewController
6. copy the storyboard id and restoration id to the new UIViewController
7. drag drop the tableview to your viewcontroller source file to create a outlet for the tableview, and name the outlet to tableView, so it has the same name as UITableViewController.
8. From storyboard, select the UIViewController tableview, and then open connection inspector, delete the datasource and delegate outlets. And then create a new outlet to the new UIViewController
9. check other action and outlet from the old UITableViewController storyboard and create the same one on the new UIViewController
10. In the UIViewController source file, if UITableViewController only uses dynamic cell, then simply fix the compile error by deleting the override keyword in the related function.
If the original UITableViewController uses static cell in storyboard, then it is more complex. First changing the storyboard cell to dynamic cell, and then creating the derived table cell class for each table cell type. Then implementing the datasource delegate method to provide the row and section information, finally, when creating each tablecell row, associate the table cell with the existing outlet variable.
11. build and run the project to verify the function
For existing UITableViewController, the below steps can be used to convert it to UIViewController with a UITableView
1. open storyboard, and add a new UIViewController,
2. select the old tableview object, and press option button and drag-drop it to the new viewcontroller. This will copy the tableview to the new UIViewController
3. Optionally, if the new UIViewController belongs to a navigation controller, then after creating the segua, then add a navigation item to the new UIViewController to customize the viewcontroller title, and then add bar button item to customize the left and right navigation bar button item
4. In the original uitableviewcontroller source file, in the class definition,
replace
UITableViewController
with
UIViewController, UITableViewDataSource, UITableViewDelegate
5. go back to storyboard editor, and change the new UIViewController's class to your class name6. copy the storyboard id and restoration id to the new UIViewController
7. drag drop the tableview to your viewcontroller source file to create a outlet for the tableview, and name the outlet to tableView, so it has the same name as UITableViewController.
8. From storyboard, select the UIViewController tableview, and then open connection inspector, delete the datasource and delegate outlets. And then create a new outlet to the new UIViewController
9. check other action and outlet from the old UITableViewController storyboard and create the same one on the new UIViewController
10. In the UIViewController source file, if UITableViewController only uses dynamic cell, then simply fix the compile error by deleting the override keyword in the related function.
If the original UITableViewController uses static cell in storyboard, then it is more complex. First changing the storyboard cell to dynamic cell, and then creating the derived table cell class for each table cell type. Then implementing the datasource delegate method to provide the row and section information, finally, when creating each tablecell row, associate the table cell with the existing outlet variable.
11. build and run the project to verify the function
UITableViewController
ReplyDelete----------------
شركة تنظيف بالدوادمى
Wonderful article, thanks for putting this together! This is obviously one great post. Thanks for the valuable information and insights you have so provided here. phone deals
ReplyDeleteIt's so nice article thank you for sharing a valuable content. ios App development online course
ReplyDeleteWonderful article. I’m satisfied that you simply shared this helpful information with us. Thank you so much.
ReplyDeletebest android mobile app development services in pakistan
Really veru nice blog,keep updating more posts with us.
ReplyDeleteThank you.....
ios app development course
android app development course