Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone TTSplitViewController带UITabBarController_Iphone_Objective C_Ipad_Three20 - Fatal编程技术网

Iphone TTSplitViewController带UITabBarController

Iphone TTSplitViewController带UITabBarController,iphone,objective-c,ipad,three20,Iphone,Objective C,Ipad,Three20,我有一个TTSplitViewController,我试图通过以下代码在左窗格中显示UITabBarController: @implementation SplitAppController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleO

我有一个TTSplitViewController,我试图通过以下代码在左窗格中显示UITabBarController:

@implementation SplitAppController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))  {
        [self setupURLRouting];
    }

    return self;
}

- (void)setupURLRouting {
    [self routePrimaryNavigator];
    [self routeDetailsNavigator];
}

- (void)routePrimaryNavigator {

    TTURLMap* map = self.primaryNavigator.URLMap;

    // Forward all unhandled URL actions to the right navigator.
    [map from: @"*" toObject: self selector: @selector(willOpenUrlPath:)];
    [map from:@"tt://primary" toViewController:[RootViewController class]];
}
这里的RootViewController是一个UITabBarController。但是,我得到以下错误:

2011-07-08 08:04:23.739 app[3241:207] -[RootViewController topViewController]: unrecognized selector sent to instance 0x520c060
2011-07-08 08:04:23.755 app[3241:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RootViewController topViewController]: unrecognized selector sent to instance 0x520c060'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x017d95a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0192d313 objc_exception_throw + 44
    2   CoreFoundation                      0x017db0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x0174a966 ___forwarding___ + 966
    4   CoreFoundation                      0x0174a522 _CF_forwarding_prep_0 + 50
    5   app                               0x000f73ff -[TTSplitViewController updateSplitViewButton] + 176
    6   app                               0x000f75d9 -[TTSplitViewController viewDidAppear:] + 90
    7   UIKit                               0x00ae1fab -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 694
    8   UIKit                               0x00a64e4b -[UIView(Internal) _didMoveFromWindow:toWindow:] + 918
    9   UIKit                               0x00a63a60 -[UIView(Hierarchy) _postMovedFromSuperview:] + 166
    10  UIKit                               0x00a5c750 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1080
    11  UIKit                               0x00a5aaa3 -[UIView(Hierarchy) addSubview:] + 57
    12  app                               0x00083d01 -[TTBaseNavigator setRootViewController:] + 306
    13  app                               0x000841f9 -[TTBaseNavigator presentController:parentController:mode:action:] + 70
    14  app                               0x00084437 -[TTBaseNavigator presentController:parentURLPath:withPattern:action:] + 359
    15  app                               0x00084975 -[TTBaseNavigator openURLAction:] + 1320
    16  app                               0x0000c440 -[appAppDelegate application:didFinishLaunchingWithOptions:] + 848
    17  UIKit                               0x00a2bc89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
    18  UIKit                               0x00a2dd88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
    19  UIKit                               0x00a38617 -[UIApplication handleEvent:withNewEvent:] + 1533
    20  UIKit                               0x00a30abf -[UIApplication sendEvent:] + 71
    21  UIKit                               0x00a35f2e _UIApplicationHandleEvent + 7576
    22  GraphicsServices                    0x01fee992 PurpleEventCallback + 1550
    23  CoreFoundation                      0x017ba944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    24  CoreFoundation                      0x0171acf7 __CFRunLoopDoSource1 + 215
    25  CoreFoundation                      0x01717f83 __CFRunLoopRun + 979
    26  CoreFoundation                      0x01717840 CFRunLoopRunSpecific + 208
    27  CoreFoundation                      0x01717761 CFRunLoopRunInMode + 97
    28  UIKit                               0x00a2d7d2 -[UIApplication _run] + 623
    29  UIKit                               0x00a39c93 UIApplicationMain + 1160
    30  app                               0x00031342 main + 130
    31  app                               0x00002a75 start + 53
)
terminate called after throwing an instance of 'NSException'

如何修复此问题?

您的代码似乎希望RootViewController是UINavigationController的子类


如果您没有编写该代码,您可以创建一个UINavigationController子类,并使用选项卡栏控制器将其初始化为根视图控制器,然后隐藏导航栏,我认为这将给出您要查找的结果。

您的代码似乎希望RootViewController是UINavigationController的子类

如果您没有编写该代码,您可以创建一个UINavigationController子类,并使用选项卡栏控制器将其初始化为根视图控制器,然后隐藏导航栏,我认为这将给出您要查找的结果。

是否正确

[map from:@"tt://primary" toViewController:[RootViewController class]];
我的建议是

[map from:@"tt://primary" toViewController:RootViewControllerobject];
是这样吗

[map from:@"tt://primary" toViewController:[RootViewController class]];
我的建议是

[map from:@"tt://primary" toViewController:RootViewControllerobject];

EmilioPelaez说得很对,我刚刚成功地使用了类似的解决方案,而且效果很好

@implementation MainViewController

- (id)initWithNavigatorURL:(NSURL *)URL query:(NSDictionary *)query {
    MainTabBarController *mainTabBarController = [[MainTabBarController alloc] init];
    [mainTabBarController setTabURLs:[NSArray arrayWithObjects:
                                      @"tt://firstLink",
                                      @"tt://secondLink",
                                      nil]];

    self = [super initWithRootViewController:mainTabBarController];
    [mainTabBarController release];
    self.navigationBarHidden = YES;
    return self;
}

@end

EmilioPelaez说得很对,我刚刚成功地使用了类似的解决方案,而且效果很好

@implementation MainViewController

- (id)initWithNavigatorURL:(NSURL *)URL query:(NSDictionary *)query {
    MainTabBarController *mainTabBarController = [[MainTabBarController alloc] init];
    [mainTabBarController setTabURLs:[NSArray arrayWithObjects:
                                      @"tt://firstLink",
                                      @"tt://secondLink",
                                      nil]];

    self = [super initWithRootViewController:mainTabBarController];
    [mainTabBarController release];
    self.navigationBarHidden = YES;
    return self;
}

@end

我找到了另一种方法使其工作,也许是降低代码复杂性的更好方法:

使用此附加方法继承UITabBarController:

- (UIViewController *)topViewController {
   return self;
}

它工作得非常完美。

我找到了另一种方法使其工作,也许是降低代码复杂性的更好方法:

使用此附加方法继承UITabBarController:

- (UIViewController *)topViewController {
   return self;
}
它工作得很好