UIAlertView 点击按钮后控制其是否消失
2017-09-09 17:43
369 查看
新建NotDismissAlertView类,继承UIAlertView。
设置控制是否消失的标示符
重写 在-(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated代理方法里判断
具体代码如下:
NotDismissAlertView.h:
#import@interface NotDismissAlertView : UIAlertView
@property(nonatomic, assign) BOOL notDisMiss;
@end
--------------------------------------
NotDismissAlertView.m:
#import "NotDismissAlertView.h"
@implementation NotDismissAlertView
-(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated {
if (_notDisMiss)
{
return;
}
[super dismissWithClickedButtonIndex:buttonIndex animated:animated];
}
@end
-------
在初始化AlertView时设定其notDisMiss值即可
NotDismissAlertView *updateAlert = [[NotDismissAlertView alloc] initWithTitle:@"新版本提示" message:[NSString stringWithFormat:@"更新日志:\\n%@",changeLog] delegate:self cancelButtonTitle:@"前往下载" otherButtonTitles:nil, nil];
updateAlert.notDisMiss = YES;
[updateAlert show];
设置控制是否消失的标示符
重写 在-(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated代理方法里判断
具体代码如下:
NotDismissAlertView.h:
#import@interface NotDismissAlertView : UIAlertView
@property(nonatomic, assign) BOOL notDisMiss;
@end
--------------------------------------
NotDismissAlertView.m:
#import "NotDismissAlertView.h"
@implementation NotDismissAlertView
-(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated {
if (_notDisMiss)
{
return;
}
[super dismissWithClickedButtonIndex:buttonIndex animated:animated];
}
@end
-------
在初始化AlertView时设定其notDisMiss值即可
NotDismissAlertView *updateAlert = [[NotDismissAlertView alloc] initWithTitle:@"新版本提示" message:[NSString stringWithFormat:@"更新日志:\\n%@",changeLog] delegate:self cancelButtonTitle:@"前往下载" otherButtonTitles:nil, nil];
updateAlert.notDisMiss = YES;
[updateAlert show];
链接:http://www.jianshu.com/p/932b81524787
相关文章推荐
- UIAlertView点击按钮不会销毁自身View
- 给UIAlertView添加手势使点击区域外弹框消失
- 为UIAlertView上的按钮添加方法,需要重写协议中对话框按钮点击事件方法
- iOS开发>学无止境 - UITablView上下滑动控制底部按钮的出现和消失
- 根据输入框EditText是否有内容来对按钮的点击权限控制
- 将UIAlertView的按钮点击代理方式改为Block形式
- ALertDialog自定义View对话框 获得View上的输入信息 + 点击按钮满足条件后消失
- 解决通过UIAlertView按钮点击事件pop回上级页面键盘会响应问题
- 自由控制TabLayout和ViewPager结合使用时是否可以点击和滑动
- js控制一个按钮是否可点击(可使用)disabled
- jquery图片轮播,点击左右按钮轮播,可控制是否自动播放,是否循环轮播(自写)
- js图片轮播可控制是否循环轮播,点击左右按钮切换
- IOS-监听UIAlertView按钮的点击事件
- UIAlertView 按钮设置可点或者不可点击
- UIAlertView点击背景消失的方法
- iOS巅峰之点击UIAlertView的灰色部分也能dismiss消失
- js控制一个按钮是否可点击(可使用)disabled的实例
- WebView点击视频全屏按钮界面消失
- .net 2.0 点击按钮用js控制是否回发&关于vs2005的webproject补丁
- Android中实现根据EditText中内容是否完整来控制按钮是否可点击