我使用基于 View 的应用程序启动了我的 iPad 应用程序。
在前两个 View 中,我添加了表格 View 。
现在作为第三个 View ,我想将 splitView 添加到 View 中,为此我将 splitview Controller 添加到我的 xib 文件中。我该如何编写编程部分。
请提供任何有用的链接或源代码。
I am using view based class like as follows:
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
我在哪里实现代码?
提前致谢。
最佳答案
当您想切换到您的 splitview Controller 时,您需要分配/初始化它,然后您需要将您的 windows Root View Controller 设置为 splitview Controller 。
例如,在我的应用程序中,我有一个主主视图,当用户点击一个按钮时,我切换到一个 Split View。要切换到 splitview Controller ,我使用以下代码。
获取对您的应用委托(delegate)的引用
MainAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
分配并初始化您的 splitview Controller ,因此对于我的示例,左侧有一个部分列表 Controller ,右侧有一个部分详细信息 Controller :
SectionListViewController *sectionListVC = [[SectionListViewController alloc] init];
SectionViewController *sectionVC = [[SectionViewController alloc] init];
UISplitViewController *splitVC = [[UISplitViewController alloc] init];
splitVC.viewControllers = [NSArray arrayWithObjects:sectionListVC, sectionVC, nil];
appDelegate.window.rootViewController = splitVC;
[sectionListVC release];
[sectionVC release];
[splitVC release];
关于iphone - 如何在 ipad 编码中将 splitview 添加到我的基于 View 的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8601863/