设计的基本思路为:首先先创建一个工程  之后在工程上创建三个类(  FirstViewController\  SecondViewController\ ThirdViewController)
首先在 AppDelegate中创建根是视图  代码如下
AppDelegate.h

#import <UIKit/UIKit.h>
#import "FirstViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
AppDelegate.m

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

FirstViewController *firstVc=[[FirstViewController alloc]init];
//创建根视图
self.window.rootViewController=firstVc;
    self.window.backgroundColor=[UIColor grayColor];
   
   
    return YES;
}
下面好就是在工程上创建的三个类进行操作
FirstViewController.h
#import <UIKit/UIKit.h>
#import "SecondViewController.h"
@interface FirstViewController : UIViewController
//声明按钮属性
@property(strong,nonatomic)UIButton *Button;
@end
对第一个类的操作
FirstViewController.m
#import "FirstViewController.h"

@interface FirstViewController ()

@end

@implementation FirstViewController

- (void)viewDidLoad {

[super viewDidLoad];
//设置主视图的背景色
self.view.backgroundColor=[UIColor greenColor];
//创建按钮
self.Button=[[UIButton alloc]initWithFrame:CGRectMake(100, 200, 50, 50)];
    self.Button.backgroundColor=[UIColor redColor];
    [self.Button setTitle:@"Next" forState:UIControlStateNormal];
    //调用方法实现进入下一页面
    [self.Button addTarget:self action:@selector(nextPage) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.Button];
}
//进入下一页的方法时间
-(void)nextPage
{
    SecondViewController *secondVc=[[SecondViewController alloc]init];
    [self presentViewController:secondVc animated:YES completion:^{
   
       NSLog(@"欢迎进入本页面");
    }];
 
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
/*
#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
对第二个类的操作
SecondViewController.h

#import <UIKit/UIKit.h>
#import "ThirdViewController.h"
@interface SecondViewController : UIViewController
@property(strong,nonatomic)UIButton *Button;
@end
SecondViewController.m

#import "SecondViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    self.view.backgroundColor=[UIColor yellowColor];
    //返回按钮
    self.Button=[[UIButton alloc]initWithFrame:CGRectMake(100, 200, 50, 50)];
    [self.Button setTitle:@"Back" forState:UIControlStateNormal];
    [self.Button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    //调用方法实现返回上一页
    [self.Button addTarget:self action:@selector(textFrontPage) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.Button];
   
    //进入下一页的按钮
    self.Button=[[UIButton alloc]initWithFrame:CGRectMake(200, 200, 50, 50)];
    [self.Button setTitle:@"Next" forState:UIControlStateNormal];
    [self.Button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    //调用方法实现进入下一页
    [self.Button addTarget:self action:@selector(nextPage) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.Button];

}

//返回上一页的方法
-(void)textFrontPage
{
    [self dismissViewControllerAnimated:YES completion:^{
   
      NSLog(@"front page show");
    }];

}

-(void)nextPage
{
    ThirdViewController *thirdVC=[[ThirdViewController alloc]init];
    [self presentViewController:thirdVC animated:YES completion:^{
     NSLog(@"欢迎进入本页");
   
    }];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#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
对第三个类的操作
ThirdViewController.h

#import <UIKit/UIKit.h>
#import "FirstViewController.h"
@interface ThirdViewController : UIViewController
@property(strong,nonatomic)UIButton *Button;
@end
ThirdViewController.m

#import "ThirdViewController.h"

@interface ThirdViewController ()

@end

@implementation ThirdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    self.view.backgroundColor=[UIColor blueColor];
    //返回按钮
    self.Button=[[UIButton alloc]initWithFrame:CGRectMake(100, 200, 50, 50)];
    [self.Button setTitle:@"Back" forState:UIControlStateNormal];
    [self.Button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    //调用方法实现返回上一页
    [self.Button addTarget:self action:@selector(textFrontPage) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.Button];
   
    //进入首页按钮
    self.Button=[[UIButton alloc]initWithFrame:CGRectMake(200, 200, 50, 50)];
    [self.Button setTitle:@"Next" forState:UIControlStateNormal]; ;
    [self.Button setTitleColor:[UIColor redColor ] forState:UIControlStateNormal];
    //调用方法实现进入首页
    [self.Button addTarget:self action:@selector(nextPage) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.Button];
   
   
   
   
}

//返回方法
-(void)textFrontPage
{
    [self dismissViewControllerAnimated:YES completion:^{
      NSLog(@"Front page show");
     
    }];

}
//进入下一页的方法
-(void)nextPage
{
    FirstViewController *firstVc=[[FirstViewController alloc]init];
    [self presentViewController:firstVc animated:YES completion:^{
   
    NSLog(@"欢迎进入本页");
     
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#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
结果效果图
点击视图上的“Back”和“Next”按钮就会返回上一页和进入下一页

转载于:https://www.cnblogs.com/guiyangxueyuan/p/5276875.html

浅谈 iOS设计之多视图—模态视图的基本操作相关推荐

  1. 浅谈ios设计之使用表格UITableVIew设计通讯录的方法

    思路:首先自作一份或者网上下载一份通讯录的   plist   文件 之后创建工程和显示通讯录的表格 代码实现如下(全部代码) 1.创建导航栏和根视图 AppDelegate.h #import &l ...

  2. 浅谈iOS和Android后台实时消息推送的原理和区别

    http://www.52im.net/thread-286-1-1.html 前言 iOS和Android上的实时消息推送差异很大,往小了说是技术实现的差异,往大了说是系统实现理念的不同.实时消息推 ...

  3. iOS实录15:浅谈iOS Crash

    导语:在当前的iOS开发中,虽然ARC为开发者解决了手动内存管理时代 的许多麻烦,但是内存方面的问题依然是产生iOS Crash的元凶之一,本文介绍内存方面,有关僵尸对象.野指针.内存泄漏.废弃内存这 ...

  4. 浅谈数据库设计技巧(上)

    浅谈数据库设计技巧(上) 说到数据库,我认为不能不先谈数据结构.1996年,在我初入大学学习计算机编程时,当时的老师就告诉我们说:计算机程序=数据结构+算法.尽管现在的程序开发已由面向过程为主逐步过渡 ...

  5. 中鸣循迹机器人_浅谈机器人设计方法

    浅谈机器人设计方法 摘要: 机器人是人类完成智能化中非常重要的工具, 随着时代的发展, 机器 人已经在世界有了一定的发展,甚至很多国家机器人已经运用到实际的生活中 去. 而机器人的设计方法无疑是很多人 ...

  6. 浅谈工厂设计--java必备技能

    浅谈工厂设计–java必备技能 说到工厂,我就联想到了亚洲的大工厂富士康–接过订单然后按照固定的模板生产商品,其实java中工厂类中的工厂方法也是一样,接过参数,根据参数来生产需要的商品: 今天我们一 ...

  7. 浅谈购物中心设计之外立面设计注意点

    购物中心的主体定位中,可以通过外立面设计充分的发挥和展现个性,吸引八方游客,从而使购物中心的商圈辐射超越了地区的界限.具体来说,购物中心外立面设计需要注意哪些方面呢?我们今天就来浅谈购物中心设计之外立 ...

  8. 计算机中用户的分类有哪些,用户分类浅谈交互设计 -电脑资料

    说到网络产品,离不开的话题就是用户,就像传统行业的消费者, 不分类不好定位, 好的用户分类让我知道了我在追求哪些人,满足哪些人,影响哪些人.但分不好类又会错位,更糟,那怎样才能对某一款产品的用户群进行 ...

  9. [UWP]浅谈按钮设计

    一时兴起想谈谈UWP按钮的设计. 按钮是UI中最重要的元素之一,可能也是用得最多的交互元素.好的按钮设计可以有效提高用户体验,构造让人眼前一亮的UI.而且按钮通常不会影响布局,小小的按钮无论怎么改也不 ...

  10. 我的家乡网页设计_Graphic Design|康石石浅谈LOGO设计在作品集中的创作方法

    写在前面的话 平面设计范畴极广,其领域不仅限于常见的版式设计.海报设计.LOGO设计.VI设计.书籍装帧.广告设计.网页设计.在艺术留学申请过程中,学习平面设计的同学们需依据目标院校对作品集项目及页数 ...

最新文章

  1. 面对千亿客服市场:曾经人工当道,如今AI为王
  2. 【阿里云总监课第四期】时髦的云原生应用怎么写?
  3. ORACLE相关的SHELL编程
  4. 算法系列之使用赫夫曼编码的实战应用【对文件进行压缩、解压缩】
  5. fileinput 时间_JavaScript_Bootstrap Fileinput文件上传组件用法详解,最近时间空余,总结了一些关...
  6. xxl-job 2.1.1执行器源码解读
  7. Python创建简单的HTTP服务
  8. ReportViewer教程(11)-给报表特定的内容设置颜色
  9. spark 字符串操作
  10. 尝试搭建Apache+Tomcat负载均衡
  11. [转]使用.NET实现断点续传
  12. android基于xposed框架,学习笔记:Android Xposed 框架入门
  13. 专升本英语:可数名词变复数规则
  14. 电子设计(1)二极管防电源反接电路
  15. 【应用宝】腾讯应用宝 上线APP为什么上线了 无法在应用宝搜索到(解决方法)
  16. 斗地主手牌最少手数的搜索
  17. 2022年卡塔尔世界杯的“科技与狠活”
  18. c语言butter函数,butter函数
  19. 使用android.view.TouchDelegate扩大View的触摸点击区域
  20. python判断数字位数_python求数字位数的方法

热门文章

  1. 重新认识margin-top和margin-bottom
  2. 时间操作(JavaScript版)—最简单比较两个时间格式数据的大小
  3. 排序算法之二 插入排序(C++版本)
  4. 27. Minimize casting
  5. @data注解_SpringBoot入门实践(七)-Spring-Data-JPA实现数据访问
  6. CountDownLatch类使用api
  7. (day 42 - 字符翻转 ) 剑指 Offer 58 - II. 左旋转字符串
  8. 服务器配置文件设计,IM配置服务器概要的设计文件.doc
  9. 看我如何解决tomcat控制台内容输出乱码的问题?
  10. Java应用服务器对比:TomcatJettyGlassFishWildFly