}
[segment_ addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
+ [self resizeSegmentedControl];
table_ = [[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStyleGrouped];
[table_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
} return self;
}
+- (void) resizeSegmentedControl {
+ CGFloat width = [[self view] frame].size.width;
+ [segment_ setFrame:CGRectMake(width / 32.0f, 0, width - (width / 32.0f * 2.0f), 44.0f)];
+}
+
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- CGFloat width = [[self view] frame].size.width;
- [segment_ setFrame:CGRectMake(width / 32.0f, 0, width - (width / 32.0f * 2.0f), 44.0f)];
+ [self resizeSegmentedControl];
+}
+
+- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
+ [self resizeSegmentedControl];
+}
+
+- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
+ [self resizeSegmentedControl];
}
- (void) save {
+ NSString *role = nil;
+
switch ([segment_ selectedSegmentIndex]) {
- case 0: Role_ = @"User"; break;
- case 1: Role_ = @"Hacker"; break;
- case 2: Role_ = @"Developer"; break;
+ case 0: role = @"User"; break;
+ case 1: role = @"Hacker"; break;
+ case 2: role = @"Developer"; break;
_nodefault
}
- Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
- Role_, @"Role",
- nil];
+ if (![role isEqualToString:Role_]) {
+ Role_ = role;
+
+ Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ Role_, @"Role",
+ nil];
- [Metadata_ setObject:Settings_ forKey:@"Settings"];
+ [Metadata_ setObject:Settings_ forKey:@"Settings"];
- Changed_ = true;
+ Changed_ = true;
- [delegate_ updateData];
+ [roledelegate_ updateData];
+ }
}
- (void) segmentChanged:(UISegmentedControl *)control {
}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
- return 5;
+ // XXX: For not having a single cell in the table, this sure is a lot of sections.
+ return 6;
}
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
[[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
}
-- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
-{
+- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
// XXX: fix Apple's layout bug
[[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
}
- (void) showSettings {
RoleController *role = [[RoleController alloc] initWithDatabase:database_ delegate:self];
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:role];
+ CYNavigationController *nav = [[CYNavigationController alloc] initWithRootViewController:role];
if (IsWildcat_) [nav setModalPresentationStyle:UIModalPresentationFormSheet];
[container_ presentModalViewController:nav animated:YES];
}