日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 互聯(lián)網(wǎng) > 模態(tài)視圖(IOS開發(fā))

模態(tài)視圖(IOS開發(fā))

來源:程序員人生   發(fā)布時(shí)間:2014-11-17 08:53:10 閱讀次數(shù):3287次

模態(tài):模態(tài)視圖從屏幕下方滑出來,完成的時(shí)候需要關(guān)閉這個(gè)模態(tài)視圖,如果不關(guān)閉,就不能做別的事情,必須有響應(yīng)處理的含義。

主視圖控制器---》模態(tài)視圖控制器。主視圖控制器與模態(tài)視圖控制器之間為父子關(guān)系。

UIViewController類中,主要有以下兩個(gè)方法:

presentViewController:animated:completion  顯現(xiàn)模態(tài)視圖

dismissViewControllerAnimated:completion 關(guān)閉模態(tài)視圖




代碼:

ViewController.h

#import <UIKit/UIKit.h> @interface ViewController : UIViewController - (IBAction)regonclick:(id)sender; @end

ViewController.m

#import "ViewController.h" #import "RegisterViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // 如果要傳遞參數(shù)的時(shí)候,應(yīng)當(dāng)用拜托設(shè)計(jì)模式或廣播通知機(jī)制 // 這里為廣播通知機(jī)制 // 注冊(cè)1個(gè)自定義通知RegisterCompletionNotification,通知到來時(shí)候發(fā)出registerCompletion:消息,其參數(shù)notification中可以包括回傳的參數(shù),統(tǒng)1放在NSDictionary字典中 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(registerCompletion:) name:@"RegisterCompletionNotification" object:nil]; } - (void)registerCompletion:(NSNotification *)notification { // 獲得參數(shù)userInfo,是1個(gè)字典 NSDictionary *theData = [notification userInfo]; // 獲得字典的username索引值 NSString *username = [theData objectForKey:@"username"]; NSLog(@"username = %@", username); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)regonclick:(id)sender { // 使用registerViewController的ID獲得視圖控制器對(duì)象 UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIViewController *registerViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"registerViewController"]; // 設(shè)定模態(tài)視圖顯現(xiàn)和關(guān)閉時(shí)候的動(dòng)畫效果 // 垂直方向由底向上退出 registerViewController.modalPresentationStyle = UIModalTransitionStyleCoverVertical; // 顯現(xiàn)完成時(shí)調(diào)用completion代碼塊 // 代碼塊問題回頭再說 [self presentViewController:registerViewController animated:YES completion:^{ NSLog(@"Present Modal View"); }]; } @end

ResgisterViewController.h

#import <UIKit/UIKit.h> @interface RegisterViewController : UIViewController - (IBAction)done:(id)sender; @property (weak, nonatomic) IBOutlet UITextField *txtUsername; @end

ResgisterViewController.m

#import "RegisterViewController.h" @interface RegisterViewController () @end @implementation RegisterViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (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. } */ - (IBAction)done:(id)sender { // 關(guān)閉模態(tài)視圖,然后繼續(xù)調(diào)用代碼塊 [self dismissViewControllerAnimated:YES completion:^{ // 代碼塊 NSLog(@"Modal View done"); // 創(chuàng)建1個(gè)以u(píng)sername為索引的字典對(duì)象 NSDictionary *dataDict = [NSDictionary dictionaryWithObject:self.txtUsername.text forKey:@"username"]; [[NSNotificationCenter defaultCenter] postNotificationName:@"RegisterCompletionNotification" object:nil userInfo:dataDict]; }]; } @end


生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 免费看91的网站 | 丝袜 亚洲 另类 欧美 综合 | 日本久久久久久久久 | 国产一区二区三区在线免费 | 国产精品一区二区在线观看 | 99国产精品视频免费观看一公开 | 福利在线影院 | 久久成人免费视频 | 欧美日韩精品免费观看 | 爱情岛论坛首页网址 | 国产中文在线视频 | 国产91在线观 | 亚洲欧洲精品成人久久奇米网 | 亚洲视频在线免费观看 | 亚洲综合在线一区 | 国产成人高清视频 | 日韩国产在线播放 | 日韩免费在线 | 综合一区二区三区 | 成人黄色免费网站 | 久久午夜精品 | 国产免费视频在线 | 国产精品一区二区三区四区 | 99精品久久 | youjizz日本人| 99爱免费视频 | 丁香婷婷网 | 精品小视频 | 日韩欧美在线视频观看 | 成人av一区二区三区 | 亚洲一区二区三区高清 | www.婷婷色 | 成人久久久精品乱码一区二区三区 | 精品久久中文 | 69视频播放 | 成人免费国产视频 | 欧美日韩国产三区 | 99久久精约久久久久久清纯 | 二区三区在线 | 免费av一级片 | 99在线精品视频 |