国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

十九,iOS對類似alertView彈框進行單例的應用避免在網絡請求時重復信息的彈出

2019-11-06 09:58:22
字體:
來源:轉載
供稿:網友

1,首先是對所有的彈窗的類型進行判斷是不是只需要彈一次就好了如果只需要彈一次就使用單例的方法來使用

首先聲明定義使用單例來處理:

+(AlertView *)sharedInstance;

+(AlertView *)sharedInstance{    static AlertView *sharedInstance = nil;    static dispatch_once_t onceToken;    dispatch_once(&onceToken, ^{        sharedInstance = [[self alloc] initWithFrame:[[UIScreen mainScreen] bounds]];        sharedInstance -> _alertArray = [NSMutableArray array];        [sharedInstance setIsShareInstance:YES];    });    return sharedInstance;}

這樣的話這個彈框只會彈最后一個;

2,彈框信息不同需要不重復的數據給用戶彈框提醒,則使用正常的封裝方法來使用

#import "AlertView.h"

@PRoperty (nonatomic ,strong) AlertView *alert;

    _alert = [[AlertView alloc]init];使用方法

 [_alert showTitle:@"1234" message:@"是否取消" buttonTitle:@"取消" buttonBlock:^{        NSLog(@"1234");    } otherTitle:@"確定" otherBolck:^{        [_alert hide];                NSLog(@"123445yuuu");    }];

3,兩個互不影響

4,地址如下

https://github.com/wang6177ming123/alertSingleton


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 清水河县| 府谷县| 通道| 荥经县| 余江县| 铜川市| 革吉县| 松江区| 涡阳县| 东丰县| 石屏县| 许昌市| 象山县| 荃湾区| 灵川县| 麦盖提县| 普定县| 鄂伦春自治旗| 蒲江县| 监利县| 松潘县| 五华县| 神木县| 册亨县| 咸宁市| 巴林左旗| 盘锦市| 汪清县| 荃湾区| 红安县| 虎林市| 且末县| 电白县| 北票市| 新兴县| 营山县| 昭觉县| 大关县| 蒲江县| 景德镇市| 恩施市|