iOS编程------UIAlertController
来源:互联网 发布:八爪鱼采集器mac版 编辑:程序博客网 时间:2024/04/27 21:54
//// AppDelegate.h// UIAlertViewController//// Created by l on 15/9/4.// Copyright (c) 2015年 . All rights reserved.//#import <UIKit/UIKit.h>@interface AppDelegate : UIResponder <UIApplicationDelegate>@property (strong, nonatomic) UIWindow *window;@end//// AppDelegate.m// UIAlertViewController//// Created by l on 15/9/4.// Copyright (c) 2015年 . All rights reserved.//#import "AppDelegate.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. return YES;}//////////////////////////////////////////////////////////////////// ViewController.h// UIAlertViewController//// Created by l on 15/9/4.// Copyright (c) 2015年 . All rights reserved.//#import <UIKit/UIKit.h>@interface ViewController : UIViewController@end//// ViewController.m// UIAlertViewController//// Created by l on 15/9/4.// Copyright (c) 2015年 . All rights reserved.//#import "ViewController.h"@interface ViewController ()@property (nonatomic, strong) UIAlertController *alertController;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; /* UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"AlertController" message:@"this is a alertConttoller" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil]; //添加事件 [alertController addAction:cancel]; //模态显示alertController //presentViewController: 为模态显示方式 //animated: 为模态显示的时候是否做动画 //completion: 为显示出来后,要执行的block块 [self presentViewController:alertController animated:YES completion:nil];//写在这里是错误的!!! */ _alertController = [UIAlertController alertControllerWithTitle:@"AlertController" message:@"this is a alertController" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil]; [_alertController addAction:cancel]; // Do any additional setup after loading the view, typically from a nib.}//一个controller 什么时候它的view才会被显示出来呢?//当controller.view被添加到父视图上面的时候//先执行viewWillAppear 后执行viewDidAppear// 因此 当视图被显示出来的时候,执行的是 vieDidAppear//同时只能给view设置一个rootVC,如果把一个controller的展示写在rootVC的viewDidLoad 和loadView里面,会产生逻辑混乱,window不知道该加载哪个根视图控制器.- (void)viewDidAppear:(BOOL)animated{ [self presentViewController:_alertController animated:YES completion:nil];}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- iOS编程------UIAlertController
- iOS,UIAlertController
- ios UIAlertController
- iOS UIAlertController
- iOS - UIAlertController
- iOS UIAlertController
- ios UIAlertController
- iOS UIAlertController
- iOS UIAlertController
- iOS开发-UIAlertController
- iOS 8 UIAlertController
- iOS 8 UIAlertController 控件
- IOS初级:UIAlertController
- iOS开发--自定义UIAlertController
- iOS 开发之UIAlertController
- iOS - UIAlertController相关用法
- ios UIAlertController学习
- iOS UIAlertController提示框
- IOS 异步下载图片
- 开源中国源码学习UI篇(三)之ViewPager+Fragment的使用分析
- Android.mk简介
- lintcode-矩阵的之字型遍历 -185
- JSON对象长度和遍历方法
- iOS编程------UIAlertController
- c++ primer第五版(中文)习题答案 第十章第四节第一小节-插入迭代器
- Android应用程序打包时,出现错误:"XXX" is not translated in "af" (Afrikaans), "am" (Amharic), "ar" (Arabic).....
- ptrdiff_t学习
- 虚拟机网络调试
- HDOJ 2034 A-B c++
- Maven插件编写
- 深入理解maven及应用
- OpenCV - Operations on Arrays