だから私はUIButton
それがクリックされた後に移動しようとしています。
_addMoreFields
ボタンがクリックされた後、メソッドが呼び出されます。
_addMoreFieldBtn
グローバルUIButton
です。クリックしても何も起こりません。
addSubView
奇妙な部分は、コードをコメントアウトするとボタンが動くことです。
そのコードを保持すると、ボタンは移動しません。
何か案は?
-(void)movePlusButton {
NSLog(@"Moving button");
[UIButton beginAnimations:nil context:nil];
[UIButton setAnimationDuration:0.3];
_addMoreFieldsBtn.center = CGPointMake(30,30);
[UIButton commitAnimations];
}
- (IBAction)addMoreFields:(id)sender {
CGRect currentBtnFrame = [(UIButton *)sender frame];
CGPoint org = currentBtnFrame.origin;
UILabel *whoWasIn = [[UILabel alloc] initWithFrame:CGRectMake(110, org.y, 85, 21)];
whoWasIn.text = @"test";
UITextField *whoWasInField = [[UITextField alloc] initWithFrame:CGRectMake(59, whoWasIn.frame.origin.y+40, 202, 30)];
whoWasInField.placeholder = @"test2";
UILabel *with = [[UILabel alloc] initWithFrame:CGRectMake(136, whoWasInField.frame.origin.y+40, 49, 21)];
with.text = @"with";
whoWasInField.borderStyle = UITextBorderStyleRoundedRect;
UITextField *withField = [[UITextField alloc] initWithFrame:CGRectMake(59, with.frame.origin.y+40, 202, 30)];
withField.placeholder = @"test3";
withField.borderStyle = UITextBorderStyleRoundedRect;
[_homeView addSubview:whoWasIn];
[_homeView addSubview:with];
[_homeView addSubview:whoWasInField];
[_homeView addSubview:withField];
[self movePlusButton];
}
注:フレームを変更しようとしましたが、同じ問題が発生します。新しい場所から既存の場所にアニメーションを開始します。