欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

IOS四種反向傳值的方法-創(chuàng)新互聯(lián)

方法一:使用target-action設(shè)計(jì)模式

榮昌ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

    代碼如下:(由根視圖推出子視圖,再由子視圖推出根視圖,在推出根視圖時,子視圖傳一個color的屬性給根視圖,用來修改根視圖的背景顏色)

根視圖控制器代碼:

//.m文件
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    
    [self createButton];
}

- (void)createButton
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(10, 30, 300, 40);
    [btn setTitle:@"進(jìn)入下一個視圖控制器" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5;
    
    btn.backgroundColor = [UIColor blackColor];
    
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
}

- (void)btnClick
{
    Sub1ViewController * sub1 = [[Sub1ViewController alloc]init];
    
    sub1.view.backgroundColor = [UIColor blueColor];
    
    sub1.target = self;
    
    sub1.action = @selector(changeColor:);
    
    [self presentViewController:sub1 animated:YES completion:nil];
}

- (void)changeColor:(UIColor *)color
{
    self.view.backgroundColor = color;
}

子視圖代碼:

//.h文件

@interface Sub1ViewController : UIViewController
@property (assign,readwrite,nonatomic)id target;
@property (assign,readwrite,nonatomic)SEL action;
@end

//.m文件
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self createPopToRootViewBtn];
}

- (void)createPopToRootViewBtn
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(10, 30, 300, 40);
    [btn setTitle:@"進(jìn)入根視圖控制器" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5;
    
    btn.backgroundColor = [UIColor blackColor];
    
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
}

- (void)btnClick
{
    if ([_target respondsToSelector:_action])
    {
        [_target performSelector:_action withObject:[UIColor orangeColor]];
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}

方法二:通知

//.m根視圖
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    
    [self createButton];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"ChangeColor" object:nil];
}

- (void)createButton
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(10, 30, 300, 40);
    [btn setTitle:@"進(jìn)入下一個視圖控制器" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5;
    
    btn.backgroundColor = [UIColor blackColor];
    
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
}

- (void)btnClick
{
    Sub1ViewController * sub1 = [[Sub1ViewController alloc]init];
    
    sub1.view.backgroundColor = [UIColor blueColor];
    
    [self presentViewController:sub1 animated:YES completion:nil];
}

- (void)changeColor:(NSNotification *)nofi
{
    self.view.backgroundColor = [nofi.userInfo objectForKey:@"color"];
}

子視圖代碼

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self createPopToRootViewBtn];
}

- (void)createPopToRootViewBtn
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(10, 30, 300, 40);
    [btn setTitle:@"進(jìn)入根視圖控制器" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5;
    
    btn.backgroundColor = [UIColor blackColor];
    
    [[NSNotificationCenter defaultCenter]postNotificationName:@"ChangeColor" object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor orangeColor],@"color", nil]];
    
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
    
    
}

- (void)btnClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

方法三:代碼塊

    根視圖代碼:

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    
    [self createButton];
}

- (void)createButton
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(10, 30, 300, 40);
    [btn setTitle:@"進(jìn)入下一個視圖控制器" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5;
    
    btn.backgroundColor = [UIColor blackColor];
    
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
}

- (void)btnClick
{
    Sub1ViewController * sub1 = [[Sub1ViewController alloc]init];
    
    sub1.view.backgroundColor = [UIColor blueColor];
    
    sub1.MyBlock = ^(UIColor * color)
    {
        self.view.backgroundColor = color;
    };
    
    [self presentViewController:sub1 animated:YES completion:nil];
}

子視圖代碼

//.h文件
@interface Sub1ViewController : UIViewController
@property (copy,nonatomic,readwrite)void (^MyBlock)(UIColor * color);
@end
//.m文件
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self createPopToRootViewBtn];
}

- (void)createPopToRootViewBtn
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(10, 30, 300, 40);
    [btn setTitle:@"進(jìn)入根視圖控制器" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5;
    
    btn.backgroundColor = [UIColor blackColor];
    
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
    
    
}

- (void)btnClick
{
    _MyBlock([UIColor orangeColor]);
    [self dismissViewControllerAnimated:YES completion:nil];
}

方法四:代理-協(xié)議

根視圖代碼

//.h
#import <UIKit/UIKit.h>
#import "Sub1ViewController.h"
@interface ViewController : UIViewController<Sub1ViewControllerDelete>

@end
//.m
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    
    [self createButton];
}

- (void)createButton
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(10, 30, 300, 40);
    [btn setTitle:@"進(jìn)入下一個視圖控制器" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5;
    
    btn.backgroundColor = [UIColor blackColor];
    
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
}

- (void)btnClick
{
    Sub1ViewController * sub1 = [[Sub1ViewController alloc]init];
    
    sub1.view.backgroundColor = [UIColor blueColor];
    sub1.delegate = self;
    [self presentViewController:sub1 animated:YES completion:nil];
}

- (void)changeColor:(UIColor *)color
{
    self.view.backgroundColor = color;
}

子視圖控制器

//.h文件
#import <UIKit/UIKit.h>

@protocol Sub1ViewControllerDelete <NSObject>
- (void)changeColor:(UIColor *)color;
@end

@interface Sub1ViewController : UIViewController
@property (assign,nonatomic,readwrite)id <Sub1ViewControllerDelete>delegate;
@end
//.m文件
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self createPopToRootViewBtn];
}

- (void)createPopToRootViewBtn
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    btn.frame = CGRectMake(10, 30, 300, 40);
    [btn setTitle:@"進(jìn)入根視圖控制器" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5;
    
    btn.backgroundColor = [UIColor blackColor];
    
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
    
    
}

- (void)btnClick
{
    [_delegate changeColor:[UIColor orangeColor]];
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

本文題目:IOS四種反向傳值的方法-創(chuàng)新互聯(lián)
當(dāng)前鏈接:http://aaarwkj.com/article48/ddodep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計(jì)公司、網(wǎng)站內(nèi)鏈、商城網(wǎng)站、響應(yīng)式網(wǎng)站ChatGPT、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)
久久这里只有精品蜜桃| 国产免费高清av在线| 亚洲av色国产精品色午含羞草| 日韩性视频激情在线一区| 亚洲欧美日韩国产一区| 最新日韩av一区二区| 欧美美女午夜福利视频| 国产精品一区二区av不卡| 四虎国产最新在线免费| jvid视频在线观看免费| 亚洲成人日韩国产欧美| 黄色国产传媒在线播放| 精品国产91高清在线观看| 亚洲最色最黄大片在线视频| 免费在线观看性生活视频| 久久国产精品99久久久| 蜜桃av在线观看一区二区| 蜜桃精品视频在线播放| 国产中文字幕一区二区在线观看| 国产成av人片乱码色午夜| 国产成年人在线免费观看| 亚洲性图中文字幕在线| 乱码日本欧美一区二区| 欧美日韩丝袜一区二区| 日韩一区二区中文字幕| 婷婷色悠悠,色悠悠激情啪啪| 婷婷六月亚洲中文字幕| 亚洲精品国产av一区| 日日干天天日夜夜操| 欧美亚洲国语精品一区二区| 新人妻一区二区在线视频| 粉嫩一区二区三区精品视频| 亚洲成人高清av在线| 六月丁香花五月婷婷| 亚洲精品丝袜成人偷拍| 国产精品免费网站在线观看| 日本免费一区二区三区等视频| 日本人妻免费在线观看| 91国内偷拍富婆国内精品对白 | 日本精彩视频一区二区| 最新日韩av一区二区|