Question

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.

Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top