So I am ma开发者_运维技巧king an iPhone program and for some odd reason the title of my UIButtons will not show... am I missing something??
I get no errors or even warnings on compilation and my buttons and everything appear, just the title is not being shown....
FurballViewController.m ... -(void)loadView { UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btn setFrame:CGRectMake(20, 50, 280, 40)]; [btn setTitle:@"Stupid Title Wont Work" forState:UIControlStateNormal]; [self.view addSubview:btn]; [btn release]; } ...
Did you try to set the title text color? It could be white.
i figured it out guys. I released the btn. I suppose when an object is initialized without alloc you dont release it. This code works:
FurballViewController.m ... -(void)loadView { UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btn setFrame:CGRectMake(20, 50, 280, 40)]; [btn setTitle:@"Stupid Title Wont Work" forState:UIControlStateNormal]; [self.view addSubview:btn]; //[btn release]; } ...
精彩评论