我发现自己需要从视图访问视图控制器。可可编程的概念或技术问题
这里是方法
-(void)changePageView:(UIViewController*)newviewcont withtransitiontype:(int)t andtransitionspeed:(int)s
{
//Remove whatever view is currently loaded at index 0, this index is only to be used by "page" views
UIView *oldview = [self.view.subviews objectAtIndex:0];
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:s];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[newviewcont viewWillAppear:YES];
//[oldview viewWillDisappear:YES];
[oldview removeFromSuperview];
[self.view insertSubview:newviewcont.view atIndex:0];
//[oldview viewDidDisappear:YES];
[newviewcont viewDidAppear:YES];
}
基本上,我试图写由该根控制器称为换出subviewcontorllers从rootcontrollers观点查看通用视图开关方法。
我通过一个子视图控制器,并能够删除当前子视图。但为了做适当的视图切换动画,我需要访问当前视图视图控制器。这是错误的方法,可以完成吗?
他可能不想要一个导航栏(你可以实现视图切换) – hhafez 2009-03-02 00:17:10
你是对的。我确实有错误的做法。基本上我是在与MVC模式作斗争。我仍然试图了解如何在某些情况下应用MVC,但至少可以取得进展! – michael 2009-05-19 17:18:55