【问题标题】:Customising iOS InAppSettingsKit gives different results on iPhone compared to simulator与模拟器相比,自定义 iOS InAppSettingsKit 在 iPhone 上会产生不同的结果
【发布时间】:2012-12-08 18:06:13
【问题描述】:

我正在尝试更改 InAppSettingKit 视图控制器的背景颜色。

我已经尝试子类化和覆盖 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;
}

我尝试为 UIColor 创建一个类别:

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

无论我尝试什么,模拟器都会显示正确的(预期的)行为,但我的 iPhone 会显示默认的组表背景。

有什么想法可以解决这个问题吗?也许这就是我在我的应用委托中创建 InAppSettingsViewController 实例的方式...?

- (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:版本 4.5.2 (4G2008a) iOS 部署目标:5.1 iPhone 上的 iOS:6.0.1 (10A523)

【问题讨论】:

  • 您是否尝试过从 iPhone 中删除应用程序并重新部署?
  • 是的,好几次!我添加了新功能(例如,编辑标题、更改图标)只是为了确保重新安装。

标签: ios inappsettingskit


【解决方案1】:

好的,所以我在阅读了SO上的其他内容后找到了答案,这让我想得更远了。

使用以下方法初始化我的子类 IASKAppSettingsViewController:

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

并添加我自己的 xib 文件(以前我没有)让我可以自定义我需要的一切,然后它在 iPhone 上运行良好。

【讨论】:

    猜你喜欢
    • 2012-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    相关资源
    最近更新 更多