多视图 iPhone 应用程序

发布于 2024-12-08 16:59:35 字数 333 浏览 0 评论 0原文

我正在尝试构建一个应用程序,打开后您将看到一个包含多个元素的表格视图。单击某个元素后,您将进入一个新视图,即选项卡栏控制器。我已经创建了一个导航控制器作为我的根视图控制器,我想要弄清楚的是我是否需要将根视图控制器的功能从导航控制器元素传递到选项卡栏控制器?然后标签栏控制器可以工作吗?我一直在阅读

Beginning iPhone 4 Development: Exploring the IOS SDK [Book] by David Mark, Jack Nutting, Jeff LaMarche

第 7 章给出了如何使用选项卡栏控制器的一个很好的示例,但是我如何传递导航控制器的功能到我正在使用的标签栏控制器?

I am trying to build an application that upon opening you will see a table view, with several elements. After you click on an element you will be taken to a new view which is a tab bar controller. I have created a navigation controller as my root view controller and what I am trying to figure out is do I need to pass off the root view controller's function from the navigation controller element to the tab bar controller? And then the tab bar controller does the work? I have been reading

Beginning IPhone 4 Development: Exploring the IOS SDK [Book] by David Mark, Jack Nutting, Jeff LaMarche

Chapter 7 gives a good example of how to use a tab bar controller but how can I pass the functions of the navigation controller to the tab bar controller that I am using?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

几度春秋 2024-12-15 16:59:35

您可以在根目录和选项卡栏控制器之后使用导航控制器,如下所示:-

这是您的应用程序委托的 .h 文件:-

@interface NavTabDemoAppDelegate : NSObject <UIApplicationDelegate>
{
   IBOutlet  UINavigationController *navController;
    IBOutlet UITabBarController *TabBar;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet  UINavigationController *navController;
@property (nonatomic, retain) IBOutlet UITabBarController *TabBar;

这是您的应用程序委托的 .m 文件

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [self.window addSubview:navController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

将导航控制器和选项卡栏控制器从库拖放到main window.xib 并将出口设置为应用程序委托

在您的 tableview 视图控制器的 .h 文件中,

NavTabDemoAppDelegate *appdelegate;

在 viewdidload 的 tableview 控制器的 .m 文件中

appdelegate = [[UIApplication sharedApplication] delegate];

创建您委托的对象,只需将其写入 tableview 视图控制器的 DidSelectRowAtIndexPath

[self.navigationController pushViewController:appdelegate.TabBar animated:YES];

完成!

You can use navigation controller at root and after that tab bar controller as following way:-

this one is yr application delegate's .h file:-

@interface NavTabDemoAppDelegate : NSObject <UIApplicationDelegate>
{
   IBOutlet  UINavigationController *navController;
    IBOutlet UITabBarController *TabBar;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet  UINavigationController *navController;
@property (nonatomic, retain) IBOutlet UITabBarController *TabBar;

this one is yr app delegate's .m file

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [self.window addSubview:navController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

drag and drop navigation controller and tab bar controller from library to main window.xib and set outlets to application delegates

In yr tableview view controller's .h file, create object of yr delegate as follows

NavTabDemoAppDelegate *appdelegate;

in .m file of yr tableview controller at viewdidload

appdelegate = [[UIApplication sharedApplication] delegate];

just write this at tableview view controller's DidSelectRowAtIndexPath

[self.navigationController pushViewController:appdelegate.TabBar animated:YES];

done!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文