【发布时间】:2014-02-19 21:47:55
【问题描述】:
我正在开发一个在第二个视图控制器中带有动画的应用程序。动画完成后,我试图自动切换到下一个视图控制器。我有
完成:^(BOOL 成功){...
但它不起作用。然后我尝试了一个简单的 NSLog@"... 但这也不起作用。我猜问题是 BOOL 没有完成或注册为成功。我的动画发生并完成了......但完成 BOOL 是没有执行。请帮忙。
来自 secondViewController 的 .m 文件...
#import "secondViewController.h"
@interface secondViewController ()
@property (nonatomic,weak) IBOutlet UIImageView *animatedImage;
@end
@implementation secondViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidAppear:(BOOL)animated
{
[self moveUp:nil finished:nil context:nil];
}
- (void)moveUp:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView animateWithDuration:2.0
delay:1.0
options: (UIViewAnimationCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction)
animations:^{
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(moveDown:finished:context:)];
self.animatedImage.center = CGPointMake(160, 304);
}
completion:^(BOOL finished){
NSLog(@"Move up done");
}];
}
- (void)moveDown:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView animateWithDuration:2.0
delay:1.5
options: (UIViewAnimationCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction)
animations:^{
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(moveUp:finished:context:)];
self.animatedImage.center = CGPointMake(160, 775);
}
completion:^(BOOL finished){
[self performSegueWithIdentifier:@"backHome" sender:self];
}];
}
@end
【问题讨论】:
-
你能给我们看更多的代码吗?例如,您创建动画的部分
标签: iphone objective-c animation boolean xcode5