2010-11-01 61 views
0

我想将两个视图并排放置,就像他们在iPad的MAIL应用程序中一样。这可能与UINavigationControllerios4 sdk ipad - 我们可以把两个VIEWS窗口内?

我想并排放置两个UINavigationController

不要担心语法我只是想知道是否有可能

UINavigationConroller *left; 
UINavigationController *right; 

[WIndow addSubView: left]; 
[WIndow addSubView:right]; 
+1

对于iPad的,它是一个拆分视图控制器,而不是两个单独的控制器 – 2010-11-01 23:16:51

+0

你尝试了吗? – 2010-11-01 23:28:27

回答

1

的UIWindow直接从UIView的继承,因此有可能添加多个对象,但如果添加多个视图控制器,则只有其中一个会接收旋转事件。

执行邮件类型展示的正确方法是使用UISplitViewController,它自动处理两个视图和一个视图模式之间的转换。 'Split View-based Application'的Xcode模板甚至会设置你,这样你就可以有一个按钮来查看左边的tableview作为UIPopoverController,如果你是纵向的。

编辑:示例代码,以拆分视图控制器:

// a tiny little method to vend a new navigation controller; following Cocoa patterns, because it 
// has 'new' in the name it vends an owning reference (ie, not autoreleased, retain count +1) 
- (UINavigationController *)newController 
{ 
    UITabBarController *tabBar = [[UITabBarController alloc] init]; 
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:tabBar]; 
    [tabBar release]; 

    return navController; 
} 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    // Override point for customization after application launch. 

    // generate a split view controller 
    UISplitViewController *splitView = [[UISplitViewController alloc] init]; 

    // grab a couple of navigation controllers 
    UINavigationController *navController1 = [self newController]; 
    UINavigationController *navController2 = [self newController]; 

    // add the navigation controllers to the split view controller 
    splitView.viewControllers = [NSArray arrayWithObjects:navController1, navController2, nil]; 
    [navController1 release]; 
    [navController2 release]; 

    // and put the whole thing on screen 
    [window addSubview:splitView.view]; 
    [window makeKeyAndVisible]; 

    return YES; 
} 
+0

如果我有两个UINavigationController视图并将它们添加到窗口中;我可以让他们并排坐吗?一些如何看起来不像他们加载或占用整个屏幕。我不使用笔尖,而是在代码中手动添加它们。 – Arcadian 2010-11-02 01:29:17

+0

你真的应该使用UISplitViewController。我会给答案添加一个示例,因为格式化评论很困难...... – Tommy 2010-11-02 11:05:37

相关问题