简体   繁体   English

UINavigationController:调用viewDidLoad但不影响UI

[英]UINavigationController: viewDidLoad is called but doesn't affect the UI

I have this in the App Delegate 我在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;
}

and this in OneViewController 这在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];
}

But when I run the app in the simulator, the OneViewController screen is blank. 但是当我在模拟器中运行应用程序时,OneViewController屏幕是空白的。 It has a xib file which is just the default blank xib. 它有一个xib文件,它只是默认的空白xib。

在iOS 7中,按钮的背景颜色和标题的字体颜色都是白色的。您可以将按钮的背景颜色或按钮的标题颜色设置为黑色以使按钮显示吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 viewDidLoad中的函数dataTaskWithRequest不会影响变量 - function dataTaskWithRequest in viewDidLoad doesn't affect variable 为什么没有调用我对 viewDidLoad 的第二次覆盖? - Why doesn’t my second override of viewDidLoad get called? UIScrollView不响应scrollRectToVisible:animated:从iOS 5中的ViewDidLoad调用 - UIScrollView doesn't respond to scrollRectToVisible:animated: called from ViewDidLoad in iOS 5 尽管调用了viewDidLoad,但未出现iOS ViewController - iOS ViewController doesn't appears although viewDidLoad gets called iOS中的ViewDidLoad和UINavigationController? - ViewDidLoad and UINavigationController in iOS? 如何不在 uinavigationcontroller 中调用 viewdidload? - how to not call viewdidload in uinavigationcontroller? ios-调用方法但不更新UI - ios - Method is called but doesn't update UI UINavigationController不推送视图 - UINavigationController doesn't push a view 在 iOS13 上使用 UINavigationController 作为 UISplitViewController 的子级时未调用 ViewDidLoad 和 WillHideViewController - ViewDidLoad and WillHideViewController Not Called When Use UINavigationController as Child of UISplitViewController on iOS13 UIButton框架未按预期在viewDidLoad中进行布局 - UIButton frame doesn't layout as expected in viewDidLoad
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM