IOS页面跳转的方法

在页面跳转时,若想用pushViewController,则必须在AppDelegate设置UINavigationController,否则pushViewController无效。
并且用pushViewController从A跳往B后,在B页面自带“Back”按钮返回上一页。类似于

这样设置,在AppDelegate中

 1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 2     self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
 3     UIViewController *controllerA = [[ViewController alloc]init];
 4     UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controllerA];
 5
 6     self.window.rootViewController = nav;
 7     [self.window makeKeyAndVisible];
 8
 9     return YES;
10 }

在controllerA中的跳转页面方法中这样写

-(void)turnToOtherController{
    ControllerB *controllerB = [[ControllerB alloc]init];
    [self.navigationController pushViewController:controllerB animated:YES];
}

这样,导航条就会一直存在。若不想要导航条,那么在AppDelegate这样写

1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2     self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
3     UIViewController *controllerA = [[ViewController alloc]init];
4     self.window.rootViewController = controllerA;
5     [self.window makeKeyAndVisible];
6
7     return YES;
8 }

而下面这种方法是通用的,无需设置rootViewController。

[self presentViewController:mainView animated:YES completion:nil];//controller自带的属性

下面的则需要

[self.navigationController pushViewController:mainView animated:YES];
//必须在AppDelegate设置UINavigationController,否则pushViewController无效。
//并且使用pushViewController后,在B页面,会自带一个“Back”按钮返回上一页。
时间: 2024-08-27 09:51:19

IOS页面跳转的方法的相关文章

ios 页面跳转之间传递数据----通过delegate

主要参考了这篇博客http://mobile.51cto.com/iphone-284116.htm 主要用到了,两个类,一个delegate a类,调用b类,当b类执行之后,需要把一个数据传递给a类,a类把这个数据显示出来. 1.delegate,就这一个头文件就足够了.在类中去实现这个代理方法 #import <Foundation/Foundation.h> @protocolUIViewPassValueDelegate - (void)passValue:(NSString*)val

js中页面刷新和页面跳转的方法总结 [ 转自欢醉同学 ]

.js中cookie的基本用法简介 2009-12-15 js中页面刷新和页面跳转的方法总结 文章分类:Web前端 关键字: javascript js中页面刷新和页面跳转的方法总结 1.history.go(-1), 返回两个页面: history.go(-2); 2. history.back(). 3. window.history.forward()返回下一页 4. window.history.go(返回第几页,也可以使用访问过的URL) 例: <a href="javascri

减少手机页面跳转的方法(转)

在标签页还没有诞生的时候, 浏览器对关键词的搜索似乎只能另起窗口显示搜索结果.且这些结果页散乱无序,假若再返回某一页面,就要从桌面一堆窗口里或者一长串任务栏内去翻找,相信现在用惯有标签页浏览器的同学,应该没有谁会愿意再去用这样的产品.这是一个典型的页面跳转例子,并且散乱无序是用户很头痛的事情.在用户对操作体验越来越重视的今天,让用户无形中享受我们精心设计的操作体验越发显的重要.通过减少页面跳转,减少用户的重复操作就是其中重要的一点,下面列举了一些常见的交互展现形式. 1.浮动弹窗 为了避免跳转页

Web设计中打开新页面或页面跳转的方法 js跳转页面

Web设计中打开新页面或页面跳转的方法 一.asp.net c# 打开新页面或页面跳转 1. 最常用的页面跳转(原窗口被替代):Response.Redirect("newpage.aspx"); 2. 利用url地址打开本地网页或互联网:Respose.Write("<script language=&apos;javascript&apos;>window.open(&apos;"+ url+"&apos;)

asp.net页面跳转的方法

1.超链接 2.response.Redirect(“UrlString”) 过程: 浏览器操作--服务器编译--发回页面--浏览器按新URl发出请求--服务器响应新URl请求--编译新页面--发回浏览器 3.Server.Transfer(“UrlString”) 4.PostBackUrl 凡是具有IButtonControl借口的控件都有PostBackUrl属性,用来定义提交至那个页面地址.(可以是本站也可以使外站) 这种方法的跳转,目标页面可以调用原页面中控件的值. asp.net页面

iOS页面跳转及数据传递

iOS页面跳转: 第一种 [self.navigationController pushViewController:subTableViewController  animated:YES]; //描述:通过 NSNavigationBar 进行跳转 [self.navigationController popViewControllerAnimated:YES]; //描述:在子视图返回到上级视图 第二种 UIViewController *control = [[UIViewControl

PHPの页面跳转-常见方法

PHP页面跳转一.header()函数 header()函数是PHP中进行页面跳转的一种十分简单的方法.header()函数的主要功能是将HTTP协议标头(header)输出到浏览器. header()函数的定义如下: void header (string string [,bool replace [,int http_response_code]]) 可选参数replace指明是替换前一条类似标头还是添加一条相同类型的标头,默认为替换. 第二个可选参数http_response_code强

Android--延迟页面跳转实现方法

方法一: new Handler(new Handler.Callback() { //处理接收到的消息的方法 @Override public boolean handleMessage(Message arg0) { //实现页面跳转 startActivity(new Intent(getApplicationContext(),MainActivity.class)); return false; } }).sendEmptyMessageDelayed(0, 3000); //表示延时

蓝懿 iOS 页面跳转和正反向调用

今天上课讲了页面跳转和正反向调用: 跳到下一页面:   [self presentViewController:v animated:YES completion:nil]; 返回上一页面:[self dismissViewControllerAnimated:YES completion:nil]; 应用程序的生命周期: 1.已经完成加载 2.已经变成激活 按大饼出去 1.将要失去激活 2.已经进入后台 按两下大饼回来 1.将要进入前台 2.已经变成激活 按两下大饼结束程序 将要结束程序 正向