使用主/明细应用程序更改默认视图

时间:2013-02-06 03:15:14

标签: objective-c xcode uiviewcontroller uinavigationcontroller

你可以帮我这个吗?我正在创建一个应用程序,我正在使用主/详细应用程序,然后我添加了一个名为MenuViewController的新类,我希望它是我的应用程序启动时加载的初始视图。我能够做到这一点,但我的MasterViewController不再工作,每次我点击表视图中的项目时,它假设显示另一个名为DetailViewController的视图,但自从我更改了默认视图后,它不再显示DetailViewController

这是我完成的一段代码

在appdelegate.m

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
     {
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        MenuViewController *menuView = [[[MenuViewController alloc]initWithNibName:@"MenuViewController" bundle:nil]autorelease];

        MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
        self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
        self.window.rootViewController = menuView;
        [self.window makeKeyAndVisible];
        return YES;

     }

和我的MenuViewController.m

//  Created by Jan Arman Capistrano on 2/6/13.
//  Copyright (c) 2013 Jan Arman Capistrano. All rights reserved.
//

#import "MenuViewController.h"
#import "MasterViewController.h"
@interface MenuViewController ()

@end

@implementation MenuViewController

-(IBAction)nextView:(id)sender
{
    MasterViewController *masterViewc = [[MasterViewController alloc]initWithNibName:nil bundle:nil];

    [self presentViewController:masterViewc animated:YES completion:nil];

}

1 个答案:

答案 0 :(得分:0)

似乎您的MasterViewController是从XIB实例化的。如果是这样,请检查UITableView是否有其委托和数据源绑定(可能是MasterViewController本身)

您是否尝试在- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath方法中设置breakPoint,看看它是否真的被调用了?

相关问题