문제

I have this in the 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

- (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. It has a xib file which is just the default blank xib.

도움이 되었습니까?

해결책

the button's background color and the title's font color both are white by default in iOS 7. can you set the button's background color or button's title color to black to make the button to appear?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top