我非常有兴趣创建一个非常类似于ipad中的设置的应用程序[两个方向中的拆分视图]。我想以编程方式不使用ib。 此外,我尝试创建的应用程序将是主应用程序的子视图,只需单击按钮即可使用。
我很努力。怎么还没有成功:))
对此的任何帮助都将受到高度赞赏
答案 0 :(得分:4)
我不确定你的意思 “我正在尝试创建的应用程序将是主应用程序的子视图,只需单击按钮即可使用”
但是你可以通过编程方式创建一个uisplitviewcontroller:
1)初始化你的uisplitviewcontroller
UISplitViewController *splitviewcontroller = [UISplitViewController alloc] init];
2)创建主要和详细的uiviewcontrollers
UIViewController *masterViewController = [[[UIViewController alloc] init] autorelease];
UIViewController *detailViewController = [[[UIViewController alloc] init] autorelease];
3)创建2个导航控制器,1个用于主控制器,1个用于详细视图(可选)
UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
4)将导航控制器添加到splitviewcontroller(或者只是视图控制器,如果您选择不使用导航控制器)
splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil]
5)添加你的uisplitviewcontroller ...... 假设您想通过单击按钮
以模态方式显示它[myCurrentViewController presentModalViewController:splitViewController animated:YES];
请务必阅读委托模式,了解主/详细视图之间所需的任何通信