2

I want to implement a drop-down list in an iPhone application, the same like you might have seen 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?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Dumb Code
  • 438
  • 3
  • 12

2 Answers2

2

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.

kubi
  • 48,104
  • 19
  • 94
  • 118
  • As per your instructions i think i need to imeplement a delegate method in that customized **UITableviewController** Class becuse once some one has selected some itme i need to send back a message use selected that item. and then based on selection and delegate method i can reload appropriate data. – Dumb Code Jun 10 '11 at 04:25
  • The delegate method should be in the original, calling, view controller. Otherwise that sounds right. – kubi Jun 10 '11 at 09:16
0

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.

marzapower
  • 5,531
  • 7
  • 38
  • 76
  • UIPicker requires lots of space and it looks ugly when you need to show/hide it very frequently. – Dumb Code Jun 09 '11 at 15:00
  • I found that using a `UIActionSheet` to present it is very appealing. By the way, is a matter of what you like and don't. – marzapower Jun 09 '11 at 17:33
  • You are absolutely right regarding personal prefrences and requirements. now my problem is they want to implement same dropdown as it is available in IBOOKS. LEt;s try see what we get. – Dumb Code Jun 10 '11 at 04:23