0

There's UIButton, button1 for example. I want to set its frame in the code.
I tried button1.frame = CGRectMake(20,20,50,50); but I've seen no effect. And I try to output the width in an alert: alert.message = [NSString stringWithFormat:@"%f", button1.frame.size.width], and the value is 0. I don't know why.

Spencer Williams
  • 902
  • 8
  • 26
Cuero
  • 1,169
  • 4
  • 21
  • 42

1 Answers1

1

Your UIButton is most probably not connected in the Interface Builder if it's an outlet or you haven't added it as a subview if you've created it programmatically. Also a small tip. Use NSStringFromCGRect() to see your element's frame parameter in detail.

Eugene
  • 10,006
  • 4
  • 37
  • 55
  • I'm sorry for that I put the release to the viewdidload but not viewdidunload, which results in the problem. Thanks for your answer very much. – Cuero Nov 28 '11 at 14:29