开发者

iPhone Xcode UIButton Title Will Not Appear

开发者 https://www.devze.com 2023-01-10 05:54 出处:网络
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??

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];

}

...

0

精彩评论

暂无评论...
验证码 换一张
取 消