91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

[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

红河县| 临颍县| 繁昌县| 炎陵县| 梅河口市| 平谷区| 尖扎县| 庆云县| 泉州市| 贡山| 岳西县| 那曲县| 铁岭市| 平乐县| 娱乐| 巴彦县| 宜春市| 安化县| 开阳县| 贵州省| 禄丰县| 潮安县| 宾阳县| 开封县| 吉林市| 洪洞县| 辽阳县| 赞皇县| 乐都县| 阳山县| 集贤县| 民乐县| 景德镇市| 平定县| 白河县| 蕲春县| 大安市| 五原县| 株洲市| 江华| 长海县|