iOS.iPad.03.UIModal

1、案例介绍:iPad上使用多种风格的ModalView,如图01,02,03,04,05

图01图02

图03图04

图05

2、代码

ViewController.h


#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

- (IBAction)onclick:(id)sender;

@property (weak, nonatomic) IBOutlet UISegmentedControl *segControl;

@end

ViewController.m


#import "ViewController.h"
#import "ModalViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

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

- (IBAction)onclick:(id)sender {

ModalViewController *modalViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"modalViewController"];

modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

switch (self.segControl.selectedSegmentIndex) {
case 0:
modalViewController.modalPresentationStyle = UIModalPresentationFullScreen;
break;
case 1:
modalViewController.modalPresentationStyle = UIModalPresentationPageSheet;
break;
case 2:
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;
break;
default:
modalViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
break;
}

[self presentViewController:modalViewController animated:YES completion:nil];

}
@end

ModalViewController.h


#import <UIKit/UIKit.h>

@interface ModalViewController : UIViewController

- (IBAction)onclick:(id)sender;

@end

ModalViewController.m


#import "ModalViewController.h"

@interface ModalViewController ()

@end

@implementation ModalViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}

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

- (IBAction)onclick:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
@end

3、故事版

iOS.iPad.03.UIModal,布布扣,bubuko.com

时间: 2024-08-10 14:05:24

iOS.iPad.03.UIModal的相关文章

IOS/iPad设置登录OpenVPN服务器图文介绍

1.下载安装OpenVPN Connect https://itunes.apple.com/us/app/openvpn-connect/id590379981?mt=8 2.安装完成 3.把.ovpn配置文件复制到IOS/iPad,选择用OpenVPN打开 4.选择添加 5.开始连接 6.连接完成

iOS iPad开发之Modal

1. 最普通的Modal QKSecondViewController *second = [[QKSecondViewController alloc]init]; [self presentViewController:second animated:YES completion:nil]; 2. Modal的过程可以通过2个属性去设置:modalTransitionStyle 和 modalPresentationStyle 前者决定以怎样的动画出来, 后者决定动画结束后展示的面积 /*

iOS实践03

主要目标:版本新特性界面,新浪授权界面(登录界面)的处理 任务基本完成了,基本的框架也就到这了,接下来的应该是首页获取微博了. 1.版本新特性,可以单独作为一个model,写完之加入到项目中.我们新建一个mvc方式的分组Newpart,主要应用的就是那个scrollview,有点类似于广告轮播,这个换成手动的切换图片. 2.在appdelegate中将window的根控制器换成newpartController,完成效果后在处理他们之间的逻辑. 3.添加UIScrollView来实现滚动,添加图

ios(ipad,iphone)屏幕旋转检测通用方法

在特别的场景下,需要针对屏幕旋转作特殊处理.在ios系统下实现相关的功能还是比较方便的. 我下面介绍两种方法: 1.注册UIApplicationDidChangeStatusBarOrientationNotification通知(举例:在一个viewcontroller类的viewdidload中注册该通知),示例代码如下: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarO

[ios]ipad下的splitViewController 让你的APP看起来酷酷的!

在ipad下可以使用splitViewController splitViewController下包含两个viewController 这是一种将屏幕一分为二的方式. 在水平状态下会出现成两个左右两个区域 我们通常称 左边的为master 右边的为detail 如何在master与detail之间交互呢? 当需要传递信息时,只要当前ViewController在splitViewController下 就可以使用 self.splitViewController.viewControllers

IOS学习 03 QQ登陆界面

学习IOS开发,现在做一个简单的QQ登陆界面的开发,如下图: 1.1 创建项目和设计界面,界面就如上图,两个Label,两个个text,加上一个Button登陆按键,界面比较简单,如下图. 2.2 说下属性设置,在输入QQ号码的文本框里,在属性Placeholder中输入“请输入QQ号吗”,这个属性当程序起动时,就会自动的在QQ号码的输入文本框中显示. 2.3  设置text的属性Clear Button=Appears while editing.这个属性是在程序运行时,在文本框输入QQ号码时

视频iOS之03类的合理设计

以下代码为了充分学习理解类的合理设计 1 /* 2 学生 3 成员变量:性别.生日.体重.最喜欢的颜色.养的狗(体重.毛色.吃.跑) 4 方法:吃.跑步.遛狗.喂狗 5 6 */ 7 8 #import <Foundation/Foundation.h> 9 10 // 性别枚举 11 typedef enum {// 枚举类型常量一般是以枚举名开头(规范) 12 SexMan, //0 13 SexWoman //1 14 } Sex; 15 16 // 生日结构体 17 typedef s

iOS iPad开发之横竖屏适配

1. 做横竖屏适配的时,需要判断当前状态是横屏还是竖屏,有两种方法: 第1种:[UIScreen mainScreen].bounds.size.width == 768 优点:把这个抽成宏之后,随时可以判断横竖屏, #define Lanscape ([UIScreen mainScreen].bounds.size.width == 768) 缺点:只在iOS8可行,也就是说在iOS8中横屏的width=1024,竖屏的width=768; 而在iOS7上,横竖屏的width=768 第2种

iOS代理-03

控制器---->控件(strong)强引用 控件.delegate---->控制器(strong)强引用 控件中的delegate(nonatomic,weak)弱引用 只有将控件中的delegate设置为weak才合理,不然会造成循环引用,导致控制器和子视图都无法被释放, 造成内存泄露.