亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

[IOS]Setting Bundle + StoryBoard

發布時間:2020-08-09 18:36:58 來源:網絡 閱讀:342 作者:蓬萊仙羽 欄目:移動開發

用storyboard添加一個導航欄,其中首頁有一個switch,與setting聯動,還有一個button,使用modal連接另一個viewControl,其上也有一個按鈕,按下銷毀本viewControl,回到前一頁。

實現步驟:

1.創建一個SingleView的項目,勾選上storyboard。

2.向storyboard中添加一個NavigationController,兩個ViewController,然后在NavigationController中右擊指向第一個ViewController,然后設置為rootViewController,并且將箭頭指向NavigationController。

3.將兩個ViewController的Class分別設置為DXWViewController和DXWViewController1(兩個自己創建的類,繼承自ViewController)

4.創建setting文件,并將root.plist保存一個鍵值對,key改成switch

5.修改DXWViewController(主視圖)

[IOS]Setting Bundle + StoryBoard

DXWViewController.h:

#import <UIKit/UIKit.h> #import "DXWViewController1.h" @interface DXWViewController : UIViewController<DXWFlipsideViewControllerDelegate> - (IBAction)change:(id)sender; @property (retain, nonatomic) IBOutlet UILabel *label; @property (retain, nonatomic) IBOutlet UISwitch *switchButton;  - (IBAction)showInfo:(id)sender;  @end

DXWViewController.m:

#import "DXWViewController.h"  @interface DXWViewController ()  @end  @implementation DXWViewController  -(void)viewWillAppear:(BOOL)animated {     [self changeData]; }  -(void)changeData {     NSUserDefaults *usr = [NSUserDefaults standardUserDefaults];     NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@YES,@"switch", nil];          [usr registerDefaults:dic];     ((UILabel *)self.label).text = [usr boolForKey:@"switch"]?@"開":@"關";     self.switchButton.on = [usr boolForKey:@"switch"];     //都要寫入一下     [usr synchronize]; }  - (void)viewDidLoad {     [super viewDidLoad]; 	UIApplication *app = [UIApplication sharedApplication];     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeData) name:UIApplicationWillEnterForegroundNotification object:app]; }   - (void)dealloc {     [self.switchButton release];     [_label release];     [super dealloc]; } //實現協議的方法 - (void)flipsideViewControllerDidFinish:(DXWViewController1 *)controller {     [self dismissViewControllerAnimated:YES completion:nil]; } - (IBAction)change:(id)sender {     UISwitch *switchButton = sender;     NSUserDefaults *user = [NSUserDefaults standardUserDefaults];     [user setBool:switchButton.on forKey:@"switch"];     [user synchronize];     ((UILabel *)self.label).text = [user boolForKey:@"switch"]?@"開":@"關"; } - (IBAction)showInfo:(id)sender {     UIStoryboard *strBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];     DXWViewController1 *controller = [strBoard instantiateViewControllerWithIdentifier:@"DXWViewController1"];     controller.delegate = self;     controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;     [self presentViewController:controller animated:YES completion:nil]; } @end


上圖中showInfo方法是通過代碼的方法實現跳轉到下一個view,如果是通過storyboard實現連線的方法然后跳過下一個view是這樣實現:

@“Add”是連線的ID
//連線的方法 -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {     if ([segue.identifier isEqualToString:@"Add"]) {         DXWViewController1 *controlller = segue.destinationViewController;         controlller.delegate = self;     } }


6.修改DXWViewController1(子視圖)

[IOS]Setting Bundle + StoryBoard

DXWViewController.h:

#import <UIKit/UIKit.h> @class DXWViewController1;  @protocol DXWFlipsideViewControllerDelegate - (void)flipsideViewControllerDidFinish:(DXWViewController1 *)controller; @end @interface DXWViewController1 : UIViewController @property (assign, nonatomic) id <DXWFlipsideViewControllerDelegate> delegate; - (IBAction)done:(id)sender; @end

DXWViewController.m:

#import "DXWViewController1.h"  @interface DXWViewController1 ()  @end  @implementation DXWViewController1  - (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)done:(id)sender {     [self.delegate flipsideViewControllerDidFinish:self]; } @end




向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

汝州市| 牡丹江市| 河西区| 宁德市| 惠州市| 长沙市| 连云港市| 泾源县| 乡城县| 鹤壁市| 肃南| 乌鲁木齐县| 肇源县| 陆河县| 轮台县| 方正县| 孝昌县| 大渡口区| 黔南| 玉门市| 贵定县| 绥阳县| 临洮县| 中江县| 济源市| 信阳市| 大连市| 永年县| 富民县| 商河县| 桐乡市| 台中县| 分宜县| 彭阳县| 宁陵县| 札达县| 汤阴县| 三原县| 左权县| 南京市| 民权县|