我正在尝试(在 XCode 中)创建一个选项卡式应用程序,该应用程序在其中一个选项卡中包含一个 UINavigationController,用于显示“FourthViewController”,然后当在该“FourthViewController”中按下按钮时,一个新的“ SlideViewController" 被推到 UINavigationController 上(呸!)。我在理解如何使 UINavigationController 从 FourthViewController 或 SlideViewController 中推送新的 ViewController 时遇到问题。我包括了一个流程图和一些代码,试图让我更清楚我在做什么。(为了记录,这是一个餐厅的应用程序,这就是为什么会有像“shrimpquesadilla.jpg”这样的名字。)
以下是流程图的链接,我没有足够的声誉将其嵌入帖子中:http: //i.imgur.com/lZVdn.jpg
DemoTabbedAppDelegate.h
@interface DemoTabbedAppDelegate : UIResponder <UIApplicationDelegate,
UITabBarControllerDelegate>
{
UINavigationController *globalUINavigationController;
}
... //other syntheses
@synthesize globalUINavigationController;
DemoTabbedAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)LaunchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
... /creating the first three tab ViewControllers
globalUINavigationController = [[UINavigationController alloc] initWithNibName:
@"DemoTabbedFourthViewController" bundle:nil];
... //setting last tab title and image
UIViewController *viewController4 = [[DemoTabbedFourthViewController alloc]
initWithNibName:@"DemoTabbedFourthViewController" bundle:nil];
[globalUINavigationController pushViewController:viewController4 animated:YES];
... //Starting the TabBarController and making it the rootViewController
}
DemoTabbedFourthView.m
//initialization and all that junk
- (void)goToSlide:(UIImage *)image
{
DemoTabbedSlideViewController *d = [[DemoTabbedSlideViewController alloc]
initWithImage:image];
[globalUINavigationController pushViewController:d animated:YES];
NSLog(@"test");
//what goes here to call push on the UINavigationController?
}
- (void)clickQuesadilla:(id)sender
{
[self goToSlide:[UIImage imageNamed:@"shrimpquesadilla.jpg"]];
}
DemoTabbedSlideViewController
- (id)initWithImage:(UIImage *)image
{
self = [super init];
imageView = [[UIImageView alloc] initWithImage:image];
NSLog(@"test 2");
return self;
}
如果您需要更多信息,请告诉我,我已尽力说明这一点。感谢您的时间。