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
新聞熱點
疑難解答