自封装UIAlert类:BlockAlertView
来源:互联网 发布:linux dns 添加mx记录 编辑:程序博客网 时间:2024/06/04 19:10
.h文件
typedef void (^blockAlertViewCallBackBlock)(int btnIndex);#import <Foundation/Foundation.h>@interface BlockAlertView : NSObject- (void)showAlertWithTitle:(NSString *)title msg:(NSString *)msg callbackBlock:(blockAlertViewCallBackBlock)block cancelButtonTitle:(NSString *)cancelBtnTitle otherButtonTitles:(NSString *)otherButtonTitles, ... ;@end
.m文件
#import "BlockAlertView.h"@implementation BlockAlertView{ blockAlertViewCallBackBlock _callbackBlock;}- (void)dealloc{ [_callbackBlock release]; _callbackBlock = nil; [super dealloc];}- (void)showAlertWithTitle:(NSString *)title msg:(NSString *)msg callbackBlock:(blockAlertViewCallBackBlock)block cancelButtonTitle:(NSString *)cancelBtnTitle otherButtonTitles:(NSString *)otherButtonTitles, ... ;{ if (!block) { return; } _callbackBlock = nil; //强引用 _callbackBlock = [block copy]; [self retain]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:cancelBtnTitle otherButtonTitles:nil]; if (otherButtonTitles) { [alert addButtonWithTitle:otherButtonTitles]; va_list args ; va_start(args, otherButtonTitles); NSString *title = nil; while ((title = va_arg(args, NSString *))) { [alert addButtonWithTitle:title]; } va_end(args); } [alert show]; [alert release]; alert = nil;}- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;{ _callbackBlock(buttonIndex); [self release];}@end
BlockAlertView类的使用方法:
BlockAlertView *blockAlert = [BlockAlertView new]; [blockAlert showAlertWithTitle:@"标题" msg:@"内容" callbackBlock:^(int btnIndex){ if (btnIndex == 0) { return ; } } cancelButtonTitle:@"确定" otherButtonTitles: nil]; [blockAlert release];
- 自封装UIAlert类:BlockAlertView
- UIAlert总结
- UIAlert 动画
- uialert IOS8
- UIALERT使用指南
- 自画cxGrid表格(类封装)
- Socket类自封装的实现
- Android 自封装的各种类
- Qt5.6 自写封装MessageBox类
- 自封装JedisUtil
- UIalert view一些做法!
- 自动消失的UIAlert
- iOS uialert的使用
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- net自带JSON封装管理类[通用类]
- ftp相关参数备忘
- 如何更新当前记录的某个字段等于本记录的某个字段+上一条记录的某字段之和 .
- 关于网络规划
- 固定浮动定位之fixed
- python初步学习教程
- 自封装UIAlert类:BlockAlertView
- 如何更新当前记录的某个字段等于本记录的某个字段+上一条记录的某字段之和 .
- 如何更新当前记录的某个字段等于本记录的某个字段+上一条记录的某字段之和 .
- 习氏“中国梦”登场
- 转载_Linux C调用C++库(用C封装C++接口)
- ZOJ 1243 URLs
- JPA 有用的注解
- 使用jquery设置select option选中
- 第9课 单元格的编辑