0

I'm trying to change the position of my UIButton, which was positioned and sized in interface builder. I'm stumped.

I tried this code at the end of viewDidAppear:

[_smartphoneButton setFrame:CGRectMake( 20, 20, 100, 50 )];

Nothing changes. And yet i know _smartphoneButton is valid, because _smartphoneButton.hidden = YES; works, as well as changing the UIButton image.

And suggestions?

PS, none of these work either:

_smartphoneButton.frame = CGRectMake( 20, 20, 100, 50 );

or

_smartphoneButton.center = CGPointMake(10.0f, 10.0f);

Thanks in advance!!!

4

1 に答える 1

0

CodaFi に同意し、ブレーク ポイントを設定して _smartphoneButton の値を確認します。
ただし、機能する場合でも、次の理由viewWillAppearからコードをに移動することをお勧めします。ViewController のライブ中に何度か呼び出される可能性があり、ボタンの位置を頻繁に変更することになります。 viewDidLoad
viewWillAppear

于 2013-01-16T02:22:39.943 に答える