今天,我試圖在取消後返回其默認原點。我正在使用兩個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