私は iOS が初めてで、ViewDidLoad() 関数のテキストを更新したいと考えています。
これは私のボタン機能です。ボタンをクリックするとアニメーションが発生し、値「1」が「resultText.text」に追加されます
- (IBAction)oneButton1:(id)sender {
oneBtn2.userInteractionEnabled = YES;
CGRect frame = oneBtn1.frame;
CGRect frame1 = reffButton.frame;
frame.origin.x = frame1.origin.x;
frame.origin.y = frame1.origin.y;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 3.0];
[UIView animateWithDuration:3.0 animations:^{
[oneBtn1 setTransform:CGAffineTransformMakeScale(.4, .4)];
} completion:^(BOOL finished) {
oneBtn1.hidden = YES;
price = [resultText.text intValue];
[resultText setText:[NSString stringWithFormat:@"%i", price+1]];
}];
oneBtn1.frame = frame;
[UIView commitAnimations];
}
問題: 上記のテキスト値は 1 ですが、ViewDidLoad では 0 です。
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%@", resultText.text); // output is 0 instead of 1;
}
ViewDidLoad関数でテキスト値を更新する方法を誰か教えてください...