常见的页面跳转的方法

1.//方法一presentViewController;用这种方法来推到下一个页面,有时候还需要返回到上一个页面的时候,就需要额外实现一个方法 ,与 presentViewController: 对应的返回方法为dismissViewControllerAnimated: 在第二个页面添加一个button 对其添加一个方法,方法的实现里面加上这一行代码就可以了
例如 [self presentViewController:detail animated:YES completion:nil];
//self.window.rootViewController=[[ViewController alloc]init];
2.//方法二UINavigation要求使用导航框架;UINavigationController相当于是一个容器,然后将所有的view都放到这个容器里面去
例如:[self.navigationController pushViewController:detail animated:YES];//返回代码popViewControllerAnimated
//在appdelegate中代码如下
//ViewController *view=[[ViewController alloc]init];
//UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:view];
//self.window.rootViewController=nav;

3.//方法三UITabBarController
UITabBarController *tab=[[UITabBarController alloc]init];//a.初始化一个tabBar控制器
self.window.rootViewController=tab;
UIViewController *c1=[[UIViewController alloc]init];
//c1.view.backgroundColor=[UIColor grayColor];
c1.tabBarItem.title=@”123”;

UIViewController *c2=[[UIViewController alloc]init];
//c2.view.backgroundColor=[UIColor brownColor];
c2.tabBarItem.title=@”456”;

//c.添加子控制器到ITabBarController中
//c.1第一种方式
// [tab addChildViewController:c1];
// [tab addChildViewController:c2];

//c.2第二种方式
tab.viewControllers=@[c1,c2];

4.将其他页面直接加到当前页面
[html] view plain copy
在CODE上查看代码片派生到我的代码片

view1=[[view21 alloc]initWithNibName:@"view21" bundle:nil];  
    [mainScr addSubview:view1.view];  
    view1.view.frame=CGRectMake(0, 0, 1024, 768);  

其对应的返回到前一个页面的方法可以使用

[view1 removeFromSuper];  

第四种:

introView = [[CompanyIntroViewController alloc]init];

[self.view insertSubview:introView.view aboveSubview:backImageView];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员的修养

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值