当用户单击某个按钮时,我需要我的应用程序来移动图像。这完美地工作:
视图控制器.m
#import "ndpViewController.h"
@interface ndpViewController ()
@property (nonatomic, retain) IBOutlet UIImageView *image;
-(void)movetheball;
@end
@implementation ndpViewController
@synthesize image;
int ballx, bally;
-(void)movetheball {
[UIView beginAnimations: @"MovingTheBallAround" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 1.0];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
image.frame = CGRectMake(ballx,bally,image.frame.size.width,image.frame.size.height);
[UIView commitAnimations];
}
- (void)viewDidLoad {
}
- (IBAction)calculatePush:(id)sender {
ballx = 600;
bally = 800;
[self movetheball];
}
@end
但是一旦应用程序必须执行其他操作(当用户单击按钮时),例如向标签添加文本,我会这样做:
_lizfwLabel.text=[NSString stringWithFormat:@"%.2f",lizfw];
然后应用程序将仅在第二次单击按钮时移动图像。
知道为什么会这样吗?谢谢!