开发者

iPhone Xcode UIButton Title Will Not Appear

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜