ios开发弹框提示(适配系统7,8,9)
来源:互联网 发布:js encodeuri 编辑:程序博客网 时间:2024/06/03 20:46
首先在基类的控制器定义以下属性
@property (copy, nonatomic) void(^cancleBlock)();/**<取消点击事件 */
@property (copy, nonatomic) void(^enSureBlock)();/**<确定点击事件 */
在基类的控制器中写入以下方法
#pragma mark --弹框提示--
/** 没有点击事件 */
-(void)showAlertVCContentWithoutEvent:(NSString*)content
{
NSLog(@"systemVersion-%f",[UIDevicecurrentDevice].systemVersion.floatValue );
if ([UIDevicecurrentDevice].systemVersion.floatValue >=8.0) {
NSLog(@"8.0以上");
UIAlertController* alertVC = [UIAlertControlleralertControllerWithTitle:@"温馨提示"message:content preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleCancelhandler:^(UIAlertAction *_Nonnull action) {
}]];
[selfpresentViewController:alertVC animated:YEScompletion:nil];
}
else{
UIAlertView* alertView = [[UIAlertViewalloc]initWithTitle:@"温馨提示"message:content delegate:nilcancelButtonTitle:nilotherButtonTitles:@"确定",nil];
[alertView show];
NSLog(@"8.0以下");
}
}
/** 有点击事件 */
-(void)showAlertVCContent:(NSString*)content cancleBlock:(void (^)())cancleBlock enSureBlock:(void (^)())enSureBlock
{
NSLog(@"systemVersion-%f",[UIDevicecurrentDevice].systemVersion.floatValue );
self.cancleBlock = cancleBlock;
self.enSureBlock = enSureBlock;
if ([UIDevicecurrentDevice].systemVersion.floatValue >=8.0)
{
NSLog(@"8.0以上");
UIAlertController* alertVC = [UIAlertControlleralertControllerWithTitle:@"温馨提示"message:nilpreferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *_Nonnull action) {
if (self.enSureBlock) {
self.enSureBlock();
}
}]];
[alertVC addAction:[UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:^(UIAlertAction *_Nonnull action) {
if (self.cancleBlock) {
self.cancleBlock();
}
}]];
[selfpresentViewController:alertVC animated:YEScompletion:nil];
}
else{
NSLog(@"8.0以下");
UIAlertView* alert = [[UIAlertViewalloc]initWithTitle:@"温馨提示"message:content delegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"确定",nil];
[alert show];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex)
{
case 0:
if (self.cancleBlock)
{
self.cancleBlock();
}
break;
case 1:
if (self.enSureBlock)
{
self.enSureBlock();
}
default:
break;
}
}
外部调用方法
/** 没有点击事件 */
-(void)showAlertVCContentWithoutEvent:(NSString*)content;
/** 有点击事件 */
-(void)showAlertVCContent:(NSString*)content cancleBlock:(void (^)())cancleBlock enSureBlock:(void (^)())enSureBlock;
以上就是完成了弹框事件,并且可以根据相应的点击做出处理- ios开发弹框提示(适配系统7,8,9)
- IOS-系统提示框
- ios开发 系统提示音的使用
- iOS开发问题:系统提示框是否同意获取当前位置提示框自动消失问题
- iOS开发 调用系统的震动和提示音
- iOS系统声音提示
- IOS开发-06.提示框
- iOS开发UI -- UIAlertController(提示框)
- iOS开发笔记之渐隐提示框
- iOS开发笔记-UI-提示框
- iOS开发 仿微博的下拉提示框
- iOS开发 仿微博的下拉提示框
- iOS播放系统提示音
- IOS AudioServicesPlaySystemSound 系统声音提示
- ios 简单系统提示音
- iOS 9 系统适配
- iOS开发小结 - 播放系统提示音使用总结(AudioToolbox)
- iOS 系统提示框是否同意获取当前位置提示框自动消失
- mysql通过sql文件创建数据库
- SMW0:上传EXCEL模板
- Objective-c学习笔记之集合
- 好的事情诡异诡异诡异诡异英语
- 欢迎使用CSDN-markdown编辑器
- ios开发弹框提示(适配系统7,8,9)
- Leetcode || Roman to Integer
- RVM 与 Ruby | NVM 与 Nodejs
- 流水账[0]
- ubuntu 14 安装 tmux 1.6
- Home键和返回键的区别
- 23种设计模式全解析
- 转:《Rework》摘录及感想
- Activity的加载模式