在我的应用程序中,我在View1的视图中设置了一些动画load(),首先启动它的工作,如果我被推入其他视图,并且在弹出到view1时它没有动画,我为其他人的流行视图做动画做了什么?在这里查看我的视图加载代码,
- (void)viewDidLoad
{
artext=[[NSMutableArray alloc] init];
arimage=[[NSMutableArray alloc] init];
arsound=[[NSMutableArray alloc] init];
[super viewDidLoad];
[self copysqlitetodocuments];
[self Readthesqlitefile];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"classroom.png"]];
}
我试过
- (void)viewDidAppear:(BOOL)animated
{
[self buttonmover];
[super viewDidAppear:animated];
}
它不起作用,任何人都可以帮我解决这个问题
答案 0 :(得分:0)
如果您想在视图出现时执行代码(例如动画),-viewDidLoad
是错误的地方。
您应该使用:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// ...
}
答案 1 :(得分:0)
试试viewWillAppear
-(void)viewWillAppear:(BOOL)animated
{
artext=[[NSMutableArray alloc] init];
arimage=[[NSMutableArray alloc] init];
arsound=[[NSMutableArray alloc] init];
[self copysqlitetodocuments];
[self Readthesqlitefile];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"classroom.png"]];
}
答案 2 :(得分:0)
调用viewDidLoad方法时,控制器尚未处于视图层次结构中,因此动画不起作用。
在实施 [super viewWillAppear] 方法后,您必须在 viewWillApper 中执行动画。类似的东西:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
artext = [[NSMutableArray alloc] init];
arimage = [[NSMutableArray alloc] init];
arsound = [[NSMutableArray alloc] init];
[self copysqlitetodocuments];
[self Readthesqlitefile];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"classroom.png"]];
}