Using static cells in a storyboard UIView with Xcode 4.2

喜夏-厌秋 提交于 2019-12-10 15:26:07

问题


I am attempting to create a very basic login screen, using the Storyboard designer in Xcode 4.2. I'd like a grouped table view to contain the login and password fields. There are some other elements on the view, such as a login button, a forgot password link, etc. Additionally, the background should be able to be tapped to dismiss the keyboard, when a input field has focus.

Pre-Xcode 4.2, I accomplished this with a UIView that implemented the UITableViewDataSource protocol, generated and returned cells, etc.

In Xcode 4.2, this all feels very close to be able to be done visually, with the static cell option, but you are not allowed to use static cells unless the table is part of a UITableViewController (or subclass). I don't see a way to layout the elements that I need in this scene with a TableViewController, so I'm wondering if there's a better approach here.

Here's the mocked up layout I'm going for:

Is there a way to accomplish this use case with the storyboard designer?


回答1:


1) If your view controller is not an instance of UITableViewController, this is not possible.

According to Apple's documentation (https://developer.apple.com/library/ios/#releasenotes/Miscellaneous/RN-AdoptingStoryboards/_index.html#//apple_ref/doc/uid/TP40011297):

For a table view that is the view of a UITableViewController instance, you can configure static content directly in the storyboard.

2) But UITableViewController has many limitations which prevents you to use it in many scenarios:

http://www.skylarcantu.com/blog/2009/09/24/dont-use-uitableviewcontroller-really/

Conclusion: it essentially makes the static cells in storyboard not feasible in most cases.




回答2:


Since you can customize the cells from storyboard, then I see no problem to implement that kind of UI.



来源:https://stackoverflow.com/questions/7825546/using-static-cells-in-a-storyboard-uiview-with-xcode-4-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!