当前位置: 首页 > 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.yayakq.cn/news/775741/

相关文章:

  • 北京东城区 网站建设贵阳经开区建设管理局网站
  • 网站建设样板短视频网站开发教程
  • 怎么做网站关键词优化手机微网站平台
  • 自己做的网站访问不了太原最新新闻消息
  • googl浏览器做桌面版网站网站制作的行业
  • 建站之星模板的使用没有版权可以做视频网站吗
  • 手机网站带后台源代码东坑镇网站建设
  • 网站设计的经费预算专业做网站的团队推荐
  • 做外贸最好的网站建设多人运动免费正能量网站链接
  • 温州网站关键词排名免费项目进度管理软件
  • 绵阳网站建设绵阳杭州做网站电话
  • 建设网站宣传郑州网站建设公司电话多少
  • 某个网站做拍卖预展的好处百度云链接
  • 肇庆网站建设公司哪个好优化网站做内链接
  • 中盛腾龙建设工程有限公司网站百度优化 几个网站内容一样
  • 英德住房和城乡建设部网站wordpress双栏主题
  • 产品包装设计素材网站软件开发流程书籍
  • 广告网站开发背景有什么网站可以做家教
  • 自己做的网站加载不出验证码青岛外贸网站设计
  • 网站排名突然消失google adwords关键词工具
  • 做外贸网站要注意什么app开发用什么软件
  • 网站如何paypal支付方式电子贺卡怎么制作
  • 建设银行网站查询网页字体网站
  • wordpress 建门户网站查手表的app哪个好用
  • 在网站怎么做代销页面排版
  • 怎么做文学动漫网站百度官方
  • 免费开源网站模板小型培训机构网站开发毕业设计
  • 济南企业网站推广方法找客户网
  • 代做网站公司免费xyz域名注册
  • 网站群维护方案上海网页制作报价