Note that there are some explanatory texts on larger screens.

plurals
  1. POrender dynamic form in iPhone application
    text
    copied!<p>I have to render dynamic form in iPhone application using tableview. This form may have multiple UI controls as button,textfield,lable, picker,date picker .</p> <p>I got one sample code for iPad which is able to render the dynamic form,but <a href="https://github.com/ecrichlow/iPad-Dynamic-Table-Cells" rel="nofollow">this</a> sample code is using UIPopoverController, which is not supported by iPhone application. So I am looking for some sample code which should work in iPhone.</p> <p>Below is the code which shows combo box on clicking the button in dynamic form. I need the code which should show picker with list items.</p> <p>sample code: <a href="https://github.com/ecrichlow/iPad-Dynamic-Table-Cells" rel="nofollow">https://github.com/ecrichlow/iPad-Dynamic-Table-Cells</a></p> <pre><code>- (IBAction)buttonPressed:(id)sender { [delegate rowItemWasSelected:self]; if (self.itemControlType == ControlTypeToggleButton) { ... } else if (self.itemControlType == ControlTypePopup) { ... } else if (self.itemControlType == ControlTypeCombo) { UITableViewController *popoverTable = [[[UITableViewController alloc] initWithStyle:UITableViewStylePlain] autorelease]; UIToolbar *toolbar = [[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, DEFAULT_POPOVER_WIDTH, DEFAULT_TOOLBAR_HEIGHT)] autorelease]; UIView *containerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, DEFAULT_POPOVER_WIDTH, ([self.controlSelections count] * popoverTable.tableView.rowHeight) + DEFAULT_TOOLBAR_HEIGHT)] autorelease]; UIViewController *containerViewController = [[[UIViewController alloc] init] autorelease]; UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:containerViewController]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(DEFAULT_COMBO_TEXTFIELD_MARGIN, (DEFAULT_TOOLBAR_HEIGHT - DEFAULT_COMBO_TEXTFIELD_HEIGHT) / 2, DEFAULT_POPOVER_WIDTH - (DEFAULT_COMBO_TEXTFIELD_MARGIN * 2), DEFAULT_COMBO_TEXTFIELD_HEIGHT)]; textField.delegate = self; textField.autocorrectionType = UITextAutocorrectionTypeNo; textField.autocapitalizationType = UITextAutocapitalizationTypeNone; textField.font = [UIFont systemFontOfSize:DEFAULT_COMBO_FONT_SIZE]; textField.borderStyle = UITextBorderStyleRoundedRect; textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; [textField addTarget:self action:@selector(fieldTextDidUpdate:) forControlEvents:UIControlEventEditingDidEnd]; containerViewController.view = containerView; popoverTable.tableView.dataSource = self; popoverTable.tableView.delegate = self; popoverTable.tableView.frame = CGRectMake(0, DEFAULT_TOOLBAR_HEIGHT, DEFAULT_POPOVER_WIDTH, [self.controlSelections count] * popoverTable.tableView.rowHeight); popoverController.popoverContentSize = CGSizeMake(DEFAULT_POPOVER_WIDTH, ([self.controlSelections count] * popoverTable.tableView.rowHeight) + DEFAULT_TOOLBAR_HEIGHT); popoverController.delegate = self; [toolbar addSubview:textField]; [containerView addSubview:toolbar]; [containerView addSubview:popoverTable.tableView]; optionPopoverController = popoverController; [popoverController presentPopoverFromRect:control.frame inView:control.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; // If there's currently an object that's first responder, make it resign that status for (UIView *subview in self.control.superview.subviews) { if ([subview isKindOfClass:[UITextField class]]) { if ([subview isFirstResponder]) { [subview resignFirstResponder]; [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; } } } [textField becomeFirstResponder]; } else if (self.itemControlType == ControlTypeButton) { // Don't need to do anything here. Caller passed in target and action. But in order to trigger delegate rowItemWasSelected this control type was added here. } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload