开发者

Present a UITableView as drop-down list using the iOS SDK

开发者 https://www.devze.com 2023-03-11 08:37 出处:网络
I want to implement a drop-down list in an iPhone application, the same like you might have s开发者_运维百科een in iBooks when you select PDFs/Books.

I want to implement a drop-down list in an iPhone application, the same like you might have s开发者_运维百科een in iBooks when you select PDFs/Books.

I have a slight idea how to implement it, just correct me if I am wrong:

  1. Create the button
  2. On a click event of the button define a CGRect and within the CGRect draw a LoadTableView
  3. Load TableViewData at runtime.

Is that correct? If not, how should I do it?


Here's a much better/easier way to do it.

  1. Create custom UITableViewController and associated nib. Use this class to encapsulate your tableView and data.
  2. When the user clicks on your button, instantiate your custom view controller and display it modally using presentModalViewController:animated
  3. When the user has selected an option from your popup view, call back to the parent view with the results.
  4. Dismiss your table view with dismissModalViewControllerAnimated:

This is what iBooks does with a highly customized UITableViewController.


Are you looking for a UIPickerView?

This component gives you the possibility of selecting from a custom number of elements through a dedicate table view. Use it in conjunction with a UIActionSheet to get the best results.

0

精彩评论

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