开发者

Changing rootviews view type in an iOS app

开发者 https://www.devze.com 2023-03-19 22:17 出处:网络
While creating a navigation based application, it automatically creates a root view controller which subclasses UITableViewController, but in MainWindow.xib a开发者_运维技巧s you know I can\'t see a U

While creating a navigation based application, it automatically creates a root view controller which subclasses UITableViewController, but in MainWindow.xib a开发者_运维技巧s you know I can't see a UITableView is placed under root view controller but we drag and drop a table view there. Can we simply drag and drop a UIView instead of a UITableView and change the root view controller class to sublass a uiview instead of UITableView and change its methods?

Or I must drag a UITableView in IB for the root view controller? I am a beginner and I do not want to make complicated things so what is the simplest way of using a UIView as a root. If thats not simple I will stick with the table view.


Yes you can change. You just need to change some bindings in inteface builder and change rootViewController's superclass to UIViewController instead of UITableViewController.

UPDATE

First open the rootViewController.xib and delete the tableiew from there and drag-n-drop a UIView. Bind that View to view property in file-owner. Change superclass of rootViewController from UITableViewController to UIViewController. That's it.

Here are the screenshots.

Changing rootviews view type in an iOS app

Changing rootviews view type in an iOS app

Changing rootviews view type in an iOS app

Changing rootviews view type in an iOS app

0

精彩评论

暂无评论...
验证码 换一张
取 消