[英]How to change root view controller to view controller in iphone
I am new to Iphone programming.While I am creating project I have taken root view controller class.By default Appdelegate.h,.m,root viewcontroller.h,.m, were created,first class is root view controller and 2nd class is view controller which I have taken.When I am running the project in simulator first view is displaying table view.Now what I want to do is, when I run project I want to display 2nd class ie, view controller not root view controller(I dont want to display table view first i want to display view).Is it possible to do this. 我是Iphone编程的新手。在创建项目时,我采用了根视图控制器类。默认情况下,创建了Appdelegate.h,.m,root viewcontroller.h,.m,第一类是根视图控制器,第二类是我已经采取的视图控制器。当我在模拟器中运行项目时,第一个视图正在显示表格视图。现在我要做的是,当我运行项目时,我想显示第二类,即视图控制器不是root view controller(I不想首先显示表格视图,我想显示view..s是否有可能做到这一点。 Thanks
谢谢
Yes. 是。 What you need to do is, Create an object of your 2nd class in AppDelegate.m file and assign it as a root view.
您需要做的是,在AppDelegate.m文件中创建第二类的对象,并将其分配为根视图。
Example: 例:
#import "ExampleClass.h"
ExampleClass *exp = [[ExampleClass alloc] initWithNibName:@"ExampleClass" bundle:nil]];
exp.title = @"ExampleClass";
// Navigation controller
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:exp] autorelease];
[self.window setRootViewController:self.navigationController];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.