Ios 无法使用UISplitView在TableView上添加NavigationController
我在这里有点困难,如果你认为我的问题对你来说很容易,请原谅我。 我正在尝试使用UISplitView创建应用程序。左边的第一个视图是TableView,右边的另一个视图只是普通视图 这是我在AppDelegate.m中为UISplitView编写的代码 现在,我想在TableView上添加一个导航栏,如果我使用SplitView,我不知道如何添加,但是当我使用单个TableView时,我可以添加 这是我在AppDelegate.m中使用使用TableView的单视图应用程序的代码。这是有效的Ios 无法使用UISplitView在TableView上添加NavigationController,ios,uinavigationcontroller,uisplitviewcontroller,Ios,Uinavigationcontroller,Uisplitviewcontroller,我在这里有点困难,如果你认为我的问题对你来说很容易,请原谅我。 我正在尝试使用UISplitView创建应用程序。左边的第一个视图是TableView,右边的另一个视图只是普通视图 这是我在AppDelegate.m中为UISplitView编写的代码 现在,我想在TableView上添加一个导航栏,如果我使用SplitView,我不知道如何添加,但是当我使用单个TableView时,我可以添加 这是我在AppDelegate.m中使用使用TableView的单视图应用程序的代码。这是有效的 #
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
//create UINavigationController
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
希望你能理解我想说的话。我不能发布图片,因为我没有足够的声誉。再一次问题是,如果使用UISplitView,如何在TableView中添加导航控制器?
你认为如果我使用故事板而不是使用两个XIB文件,对我来说会容易吗?希望你能帮助我
提前感谢 试试这段代码
在AppDelegate.h文件中
在AppDelegate.m文件中
我有一些错误。XCode似乎无法识别HomePlitViewController。请解释一下你是如何做到的,你是否在其他文件中定义了它?在ViewController.h中,可能?
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
//create UINavigationController
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
UINavigationController *detailNavigationController;
UINavigationController *masterNavigationController;
UISplitViewController *HomeSpilitView;
HomeSpilitViewController *HomeMster;
HomeDetailsViewController *HomeDetailsViewControllers;
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
NSMutableArray *array = [NSMutableArray array];
HomeSpilitView = [[[UISplitViewController alloc] init]autorelease];
HomeMster = [[HomeSpilitViewController alloc] initWithNibName:@"HomeSpilitViewController" bundle:nil];
masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeMster] autorelease];
HomeMster.title=@"Title home";
masterNavigationController.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];
[array addObject:masterNavigationController];
HomeDetailsViewController *HomeDetailsViewControllers = [[HomeDetailsViewController alloc] initWithNibName:@"HomeDetailsViewController" bundle:nil];
detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeDetailsViewControllers] autorelease];
detailNavigationController.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];
HomeDetailsViewControllers.title=@"details title";
HomeMster.objHomeDetailsViewcontroller=HomeDetailsViewControllers;
HomeSpilitView.delegate = HomeDetailsViewControllers;
[array addObject:detailNavigationController];
[HomeSpilitView setViewControllers:array];
[self.window setRootViewController:HomeSpilitView];
[self.window makeKeyAndVisible];
return YES;
}