The most iPhone-like interface for forms will be a grouped view of the table. This is what most users expect after using other applications that use grouped table views to add and edit structured data.
It is good practice to create enum(enumerate) for sections and for lines within sections, for example:
typedef enum {
kFormSectionFirstSection = 0,
kFormSectionSecondSection,
kFormSectionThirdSection,
kFormSections
} FormSection;
typedef enum {
kFormFirstSectionFirstRow = 0,
kFormFirstSectionSecondRow,
kFormFirstSectionRows
} FormFirstSectionRow;
...
.
( , , kFormSectionFirstSection , - kFormSectionNameFieldSection kFormSectionAddressFieldSection .., , , enum.)
?
, , :
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return kFormSections;
}
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
switch (section) {
case kFormSectionFirstSection:
return kFormFirstSectionRows;
case kFormSectionSectionSection:
return kFormSecondSectionRows;
...
default:
break;
}
return -1;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
case kFormSectionThirdSection: {
switch (indexPath.row) {
case kFormThirdSectionFourthRow: {
break;
}
default:
break;
}
}
default:
break;
}
return cell;
}
.
, . , , .
, , , enum. , , .