今天,我试图在取消后返回其默认原点。我正在使用两个VC来做到这一点。一个是tableview中的页脚控制器,另一个是模态视图,在第一个动画之后显示。每当我尝试从模态视图返回时,在完成第一个动画之后,原点仍然是相同的。这里是我使用的代码:将原点移回原位
Footer:
-(IBAction)addPerson:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
NSLog(@"%f", self.view.frame.origin.y);
self.view.frame = CGRectMake(0,-368,320,400);
[UIView commitAnimations];
self.tdModal2 = [[TDSemiModalViewController2 alloc]init];
// [self.view addSubview:test.view];
[self presentSemiModalViewController2:self.tdModal2];
}
-(void)moveBack{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
NSLog(@"%f", self.view.frame.origin.y);
self.view.frame = CGRectMake(0,368,320,400);
[UIView commitAnimations];
}
而且在模式的看法:
-(IBAction)cancel:(id)sender{
[self dismissSemiModalViewController:self];
FooterViewController *foot = [[FooterViewController alloc]init];
self.footer = foot;
// self.footer.view.frame = CGRectMake(0,35,320,400);
[self.footer moveBack];
}
我认为你的代码是错误的,你正在创建的取消方法的新FooterViewController,但你是不是分配给它的任何视图。或者如果它被自动分配,那么它将从当然的来源创建,就像它是一个新的一样;它与您以前的动画不一样。 – htafoya
另外,在iOS 4.0及更高版本中不鼓励使用[UIView beginAnimations]。您应该使用基于块的动画方法来指定您的动画。 – htafoya
@htafoya嗯。我见过的大多数例子都使用过。另外,你是否有针对所述问题的“可靠”解决方案? – 128keaton