I am very new to iOS development. Currently, I am trying to develop an iPad app for taking orders in a restaurant. The UI should be like this: http://www.dhtmlx.com/blog/wp-content/uploads/2011/02/ipad_menu_final.jpg As people suggested, it would be easier to start by creating a Master/Detail project as the basic structure. After going through a couple of tutorials, I know how to display detail contents when I select rows at master view. Now, my assumption is to add an UITableView to the detail view controller, and at each UITableView Cell, I want to add some text to describe the menu item and also an UIPickerView to let the user select the quantity of each item (like the pic in the above link). Am I on the right track? How can I add an UITextField and UIPickerView to each UITableView cell programmatically? Are there any examples or tutorials teach me how to do this? Thanks in advance.
1 - THE VIEW : Create a UITableViewCell
subclass (ex: MyMenuItemCell), with the properties you need
UIImageView
for the picture UILabel
for the price (with some CALayer
cornerRadius
, backgroundColor
, and borderColor
tweaking) UILabel
for the title describing the product UILabel
for the description UIButton
to get userAction, but handle that in another class, as this cell is the VIEW, and should hold no control logic, this is the CONTROLLER
's part. 2 - THE CONTROLLER
You UIViewController
should implement <UITableViewDatasource, UITableViewDelegate>
. (or it can directly be a UITableViewController
subclass, which provides some generic benefits, like moving the tableView when a keyboard is displayed. If you choose this 2nd option, and create the viewController programmatically, be sure to use the initWithStyle:
method)
3 - BIND VIEW with CONTROLLER
However you choose to enable 'quantity pick' :
UIStepper
(+ and - buttons) linked to a UILabel
or
UIPickerView
displayed in a UIViewController
embedded in a UIPopoverController
(or any other design you see fit)
you should write the code that triggers this action handling IN your controller, when UITableViewCell
are instantiated / reused, in UITableViewDatasource
method providing cells instances :
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.