11 #import "EditorBaseController.h"
17 NSString *TableCellIdentifierText =
@"cellIdText";
18 NSString *TableCellIdentifierSecretText =
@"cellIdSecretText";
19 NSString *TableCellIdentifierYesNo =
@"cellIdYesNo";
20 NSString *TableCellIdentifierSelection =
@"cellIdSelection";
21 NSString *TableCellIdentifierSubEditor =
@"cellIdSubEditor";
22 NSString *TableCellIdentifierMultiChoice =
@"cellIdMultiChoice";
23 NSString *TableCellIdentifierButton =
@"cellIdButton";
27 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
32 #pragma mark - Create table view cells
33 - (UITableViewCell *)tableViewCellFromIdentifier:(NSString *)identifier
36 UITableViewCell *cell = [[
self tableView] dequeueReusableCellWithIdentifier:identifier];
41 if ([identifier isEqualToString:TableCellIdentifierText])
43 [[NSBundle mainBundle] loadNibNamed:@"EditTextTableViewCell" owner:self options:nil];
44 cell = _textTableViewCell;
45 _textTableViewCell = nil;
47 else if ([identifier isEqualToString:TableCellIdentifierSecretText])
49 [[NSBundle mainBundle] loadNibNamed:@"EditSecretTextTableViewCell" owner:self options:nil];
50 cell = _secretTextTableViewCell;
51 _secretTextTableViewCell = nil;
53 else if ([identifier isEqualToString:TableCellIdentifierYesNo])
55 [[NSBundle mainBundle] loadNibNamed:@"EditFlagTableViewCell" owner:self options:nil];
56 cell = _flagTableViewCell;
57 _flagTableViewCell = nil;
59 else if ([identifier isEqualToString:TableCellIdentifierSelection])
61 [[NSBundle mainBundle] loadNibNamed:@"EditSelectionTableViewCell" owner:self options:nil];
62 cell = _selectionTableViewCell;
63 _selectionTableViewCell = nil;
65 else if ([identifier isEqualToString:TableCellIdentifierSubEditor])
67 [[NSBundle mainBundle] loadNibNamed:@"EditSubEditTableViewCell" owner:self options:nil];
68 cell = _subEditTableViewCell;
69 _subEditTableViewCell = nil;
71 else if ([identifier isEqualToString:TableCellIdentifierButton])
73 [[NSBundle mainBundle] loadNibNamed:@"EditButtonTableViewCell" owner:self options:nil];
74 cell = _buttonTableViewCell;
75 _buttonTableViewCell = nil;
77 else if ([identifier isEqualToString:TableCellIdentifierMultiChoice])
79 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
80 reuseIdentifier:identifier] autorelease];
84 NSAssert(
false,
@"Unknown table cell identifier");
90 #pragma mark - Utility functions
93 UILabel *label = [cell label];
94 UITextField *textField = [cell textfield];
97 CGFloat width = [[label text] sizeWithFont:[label font]].width;
98 CGRect frame = [label frame];
99 CGFloat delta = width - frame.size.width;
100 frame.size.width = width;
101 [label setFrame:frame];
104 frame = [textField frame];
105 frame.origin.x += delta;
106 frame.size.width -= delta;
107 [textField setFrame:frame];