Howard Sandford
Howard Sandford

Reputation: 1690

Customising iOS InAppSettingsKit gives different results on iPhone compared to simulator

I'm trying to change the background color of the InAppSettingKit view controller.

I've tried subclassing and overriding the cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
    cell.textLabel.backgroundColor = [UIColor redColor];
    cell.detailTextLabel.backgroundColor = [UIColor redColor];
    return cell;
}

I've tried creating a category for UIColor:

+ (UIColor *)groupTableViewBackgroundColor {
    return [UIColor redColor];
}

Whatever I try, the simulator shows the correct (expected) behaviour, but my iPhone shows the default group table background.

Any thoughts on how I can fix this? Perhaps it's the way I'm creating an instance of my InAppSettingsViewController in my app delegate ...?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    IASKAppSettingsViewController *iaskvc = [[IASKAppSettingsViewController alloc] init];
    i = [UIImage imageNamed:@"20-gear-2.png"];
    [[iaskvc tabBarItem] setImage:i];
    [[iaskvc tabBarItem] setTitle:@"Settings"];

    // Create the Toolbar
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    NSArray *viewControllers = [NSArray arrayWithObjects:iaskvc, nil];
    [tabBarController setViewControllers:viewControllers];

    [[self window] setRootViewController:tabBarController];
    [self.window makeKeyAndVisible];
    return YES;
}

XCode: Version 4.5.2 (4G2008a) iOS deployment target: 5.1 iOS on iPhone: 6.0.1 (10A523)

Simulator -- expected iPhone -- customisation not working

Upvotes: 1

Views: 315

Answers (1)

Howard Sandford
Howard Sandford

Reputation: 1690

Ok, so I found the answer after reading something else on SO, which made me think a little further.

Initialising my subclassed IASKAppSettingsViewController with:

MyAppSettingsViewController *iaskvc = [[MyAppSettingsViewController alloc] initWithNibName:@"MyAppSettingsViewController" bundle:nil];

and adding my own xib file (which previously I didn't have) allowed me to customise everything I needed, and it then worked fine on the iPhone.

Upvotes: 2

Related Questions