开发者

How do I create a view with a picker on the bottom and a table view on the top?

开发者 https://www.devze.com 2022-12-25 00:40 出处:网络
first time asker, long-time lurker. I am trying to create an iPhone view that has a date/time picker on the bottom half of the screen, and a grouped, single-section, four-row table view on the top ha

first time asker, long-time lurker.

I am trying to create an iPhone view that has a date/time picker on the bottom half of the screen, and a grouped, single-section, four-row table view on the top half of the screen (almost identical to the one Apple shows in Fig. 2-4 of their View Controller Programming Guide (but then never goes on to explain).

Conceptually, I think I understand that what I need is a main view with a pair of subviews - one for the picker, and one for the table view. I'm pretty sure I can make the picker function once I have it on-screen, and I'm pretty sure I can make the table view function too开发者_如何学编程. What I can't for the life of me figure out is how, programmatically speaking, to get the two views onto the screen simultaneously. I can lay it out perfectly in Interface Builder, but then it all goes to hell when I switch to Xcode...the view appears with the picker, but no table view.

Thanks, in advance, for any help you can offer.


the view appears with the picker, but no table view.

If the table view isn't assigned a data source, then it has nowhere from which to populate itself, and so it may give you the appearance of "not being there".

Have you created a view controller for this view? Is it a subclass of UITableViewController, or does it at least implement the UITableViewDelegate/UITableViewDataSource protocols? Is it set as the File's Owner in the .xib? And has it been assigned (using the connections) as your table view's delegate and dataSource?

In your .xib, are both the UITableView and the UIPickerView subviews of a top-level UIView, which is connected to your view controller's view property (i.e. for the File's Owner)?

UIView
+
|
+---UITableView
|
+---UIPickerView
0

精彩评论

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