我是 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 函数中的文本值...