2012-09-05 88 views
5

我想使用storyboard来创建我的应用程序。 我可以找到很多关于如何将它与导航或tabcontroller一起使用的信息,但我不想要它们中的任何一个。没有导航控制器的ios segues

我的目标是创建一个具有不同视图但不使用导航或tabcontroller的应用程序。 我该怎么做?

回答

2

你为什么不要他们?这好像你正在为自己工作。

你可以有一个是不可见的UI导航控制器,它只是为了推动和弹出等UIViewControllers然后默认推SEGUE类型将只是工作负责。

但是,如果你真的不想让他们,你总是可以做一个custom segue class并使用它来管理你的视图控制器堆栈。

+1

你怎么隐藏在故事板的用户界面?然后,如何以编程方式推送和弹出ViewControllers? – Crashalot

6

在IOS故事板中,如果你不想使用导航,那么你就不能使用push segue。然后,您可以使用模态赛格或自定义赛格。在模态SEGUE,有四个转变:

  1. 盖垂直
  2. 水平翻转
  3. 跨解散
  4. 偏曲

然而,所有这些预定义SEGUE动画不能瓶坯横向滑动动画segue。如果你想使用水平滑动效果,你必须使用自定义的继续。你需要覆盖这样的功能:

- (void) perform 
{ 
UIViewController *desViewController = (UIViewController *)self.destinationViewController; 

UIView *srcView = [(UIViewController *)self.sourceViewController view]; 
UIView *desView = [desViewController view]; 

desView.transform = srcView.transform; 
desView.bounds = srcView.bounds; 

if(isLandscapeOrientation) 
{ 
    if(isDismiss) 
    { 
     desView.center = CGPointMake(srcView.center.x, srcView.center.y - srcView.frame.size.height); 
    } 
    else 
    { 
     desView.center = CGPointMake(srcView.center.x, srcView.center.y + srcView.frame.size.height); 
    } 
} 
else 
{ 
    if(isDismiss) 
    { 
     desView.center = CGPointMake(srcView.center.x - srcView.frame.size.width, srcView.center.y); 
    } 
    else 
    { 
     desView.center = CGPointMake(srcView.center.x + srcView.frame.size.width, srcView.center.y); 
    } 
} 


UIWindow *mainWindow = [[UIApplication sharedApplication].windows objectAtIndex:0]; 
[mainWindow addSubview:desView]; 

// slide newView over oldView, then remove oldView 
[UIView animateWithDuration:0.3 
       animations:^{ 
        desView.center = CGPointMake(srcView.center.x, srcView.center.y); 

        if(isLandscapeOrientation) 
        { 
         if(isDismiss) 
         { 
          srcView.center = CGPointMake(srcView.center.x, srcView.center.y + srcView.frame.size.height); 
         } 
         else 
         { 
          srcView.center = CGPointMake(srcView.center.x, srcView.center.y - srcView.frame.size.height); 
         } 
        } 
        else 
        { 
         if(isDismiss) 
         { 
          srcView.center = CGPointMake(srcView.center.x + srcView.frame.size.width, srcView.center.y); 
         } 
         else 
         { 
          srcView.center = CGPointMake(srcView.center.x - srcView.frame.size.width, srcView.center.y); 
         } 
        } 
       } 
       completion:^(BOOL finished){ 
        //[desView removeFromSuperview]; 
        [self.sourceViewController presentModalViewController:desViewController animated:NO]; 
       }]; 
} 

如果你仍然有问题,你可以检查这个职位。它也有一个YouTube视频向您展示如何实现这一习俗赛格瑞:

Create Push Segue Animation Without UINavigation Controller

+0

我还发现在互联网上该解决方案:http://stackoverflow.com/questions/15139909/auto-layout-screen-rotation-and-uiview-animation/20958850#20958850 – asdfasdfads