当前位置: 首页 > news >正文

新郑做网站优化新浪微舆情大数据平台

新郑做网站优化,新浪微舆情大数据平台,郑州荥阳市疫情最新消息,睢县做网站哪家好界面切换 push和poppresent和dismiss示例程序 push和pop 在 Objective-C 中,pop 和 push 通常是与 UINavigationController 一起使用的方法,用于控制导航栈中视图控制器的跳转和回退。 push 和 pop 通常成对使用,用于实现导航栈的前进和后退功能。当用户进入新的视图控制器时…

界面切换

  • push和pop
  • present和dismiss
  • 示例程序

push和pop

在 Objective-C 中,pop 和 push 通常是与 UINavigationController 一起使用的方法,用于控制导航栈中视图控制器的跳转和回退。

  • push 和 pop 通常成对使用,用于实现导航栈的前进和后退功能。
  • 当用户进入新的视图控制器时,使用 push 方法将其加入导航栈;
  • 当用户需要返回上一个视图控制器时,使用 pop 方法从导航栈中移除当前视图控制器。

push的代码格式:

[self.navigationController pushViewController:two animated:YES];

pop的代码格式

//返回上一视图控制器
[self.navigationController popViewControllerAnimated:YES];
//返回根视图控制器
[self.navigationController popToRootViewControllerAnimated:YES];
//返回到指定的控制器
[self.navigationController popToViewController:one animated:YES];

present和dismiss

在 Objective-C 中,present 和 dismiss 是与视图控制器相关的两个重要概念,它们描述了视图控制器的呈现和关闭行为。present 用于以模态方式呈现一个新的视图控制器。dismiss 用于关闭当前模态呈现的视图控制器,返回到上一级视图控制器。

区别与联系:

  • present 和 dismiss 是相对的概念,present 用于呈现新的视图控制器,dismiss 用于关闭当前视图控制器。
  • 通常情况下,一个视图控制器被 present 之后,需要通过 dismiss 方法来关闭自己,返回到上一级视图控制器。

示例代码:

[self presentViewController:three animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];

示例程序

在这里插入图片描述
VCone.m:

#import "VCone.h"
#import "VCtwo.h"
@interface VCone ()@end@implementation VCone
@synthesize item = _item;
- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor = [UIColor redColor];_item = [[UIBarButtonItem alloc] initWithTitle:@"下一页" style:UIBarButtonItemStylePlain target:self action:@selector(pressRight)];self.navigationItem.rightBarButtonItem = _item;
}-(void) pressRight
{VCtwo* two = [[VCtwo alloc] init];[self.navigationController pushViewController:two animated:YES];}/*
#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {// Get the new view controller using [segue destinationViewController].// Pass the selected object to the new view controller.
}
*/@end

VCtwo.m:

#import "VCtwo.h"
#import "VCone.h"
#import "VCthree.h"
@interface VCtwo ()@end@implementation VCtwo
@synthesize btn = _btn;
@synthesize btn1 = _btn1;
- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor = [UIColor greenColor];_btn = [[UIBarButtonItem alloc] initWithTitle:@"上一页" style:UIBarButtonItemStylePlain target:self action:@selector(press)];self.navigationItem.leftBarButtonItem = _btn;_btn1 = [[UIBarButtonItem alloc] initWithTitle:@"下一页" style:UIBarButtonItemStylePlain target:self action:@selector(pressright)];self.navigationItem.rightBarButtonItem = _btn1;
}-(void) press
{[self.navigationController popViewControllerAnimated:YES];
}-(void) pressright
{VCthree* three = [[VCthree alloc] init];[self presentViewController:three animated:YES completion:nil];
}/*
#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {// Get the new view controller using [segue destinationViewController].// Pass the selected object to the new view controller.
}
*/@end

VCthree.m:

#import "VCthree.h"
#import "VCtwo.h"
@interface VCthree ()@end@implementation VCthree- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.self.view.backgroundColor = [UIColor yellowColor];
}-(void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{[self dismissViewControllerAnimated:YES completion:nil];
}/*
#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {// Get the new view controller using [segue destinationViewController].// Pass the selected object to the new view controller.
}
*/@end

效果图

在这里插入图片描述

http://www.hrbkazy.com/news/13570.html

相关文章:

  • 青岛哪家做网站的公司cps广告是什么意思
  • 动态网站的例子引流推广
  • 照明灯企业网站织梦模板快速排名点击工具
  • 建立 wiki 网站在线建站平台
  • 如何登录wordpressseo排名的方法
  • 用什么框架做网站快公司网站的推广
  • 政府网站开发项目技术总结书怎样在百度上打广告
  • 长沙门户网站建设宁波正规优化seo软件
  • 个人网站开发背景怎么写友情链接联盟
  • 免费营销型企业网站模板seo推广是什么
  • 东莞中小企业网站制作2022年seo还值得做吗
  • 婚恋网站哪家做的最好seo常规优化
  • 速成网站建设百度发布
  • 做网站建设公司属于诈骗嘛中文搜索引擎网站
  • 做产品网站要备案吗如何推广app
  • 机械加工网址大全seo快速排名软件方案
  • 高职示范校建设网站图片外链生成工具在线
  • software powered by wordpress做seo如何赚钱
  • 淘宝联盟网站建设不完整免费站长工具
  • 网站开发公司深圳seo排名优化技术
  • asp网站上哪做谷歌seo优化公司
  • 微信小程序下载app快速优化关键词排名
  • 德州网络四川seo选哪家
  • wordpress做的学校网站seo网站内容优化
  • 包头市住房和城乡建设局网站百度一下网址是多少
  • 网站建设厦门比百度强大的搜索引擎
  • 平面设计公司网站自己可以做网站推广吗
  • 怎样做批发网站seo的定义
  • 做网站安全维护是什么东东天津做网站的公司
  • winforms做网站免费推广渠道有哪些