UINavigationController:调用viewDidLoad但不影响UI

时间:2013-12-31 01:09:34

标签: ios objective-c uinavigationcontroller viewdidload

我在App Delegate中有这个

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];

    OneViewController *vc = [[OneViewController alloc] initWithNibName:@"OneViewController" bundle:nil];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

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

和OneViewController中的这个

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
    [button setTitle:@"Hi" forState:UIControlStateNormal];
    [self.view addSubview:button];
}

但是当我在模拟器中运行应用程序时,OneViewController屏幕是空白的。它有一个xib文件,它只是默认的空白xib。

1 个答案:

答案 0 :(得分:2)

默认情况下,iOS 7中按钮的背景颜色和标题的字体颜色均为白色。您可以将按钮的背景颜色或按钮的标题颜色设置为黑色以使按钮显示吗?