UIAlertView+Blocks.h
#import <Foundation/Foundation.h> typedef void (^DismissBlock)(int buttonIndex);
typedef void (^CancelBlock)(); @interface UIAlertView (Blocks) <UIAlertViewDelegate> + (UIAlertView*) showAlertViewWithTitle:(NSString*) title
message:(NSString*) message
cancelButtonTitle:(NSString*) cancelButtonTitle
otherButtonTitles:(NSArray*) otherButtons
onDismiss:(DismissBlock) dismissed
onCancel:(CancelBlock) cancelled; @end
//
// UIAlertView+Blocks.m
// UIKitCategoryAdditions
// #import "UIAlertView+Blocks.h" static DismissBlock _dismissBlock;
static CancelBlock _cancelBlock; @implementation UIAlertView (Blocks) + (UIAlertView*) showAlertViewWithTitle:(NSString*) title
message:(NSString*) message
cancelButtonTitle:(NSString*) cancelButtonTitle
otherButtonTitles:(NSArray*) otherButtons
onDismiss:(DismissBlock) dismissed
onCancel:(CancelBlock) cancelled { _cancelBlock = [cancelled copy]; _dismissBlock = [dismissed copy]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:[self self]
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:nil]; for(NSString *buttonTitle in otherButtons)
[alert addButtonWithTitle:buttonTitle]; [alert show];
return alert;
} + (void)alertView:(UIAlertView*) alertView didDismissWithButtonIndex:(NSInteger) buttonIndex { if(buttonIndex == [alertView cancelButtonIndex])
{
_cancelBlock();
}
else
{
_dismissBlock(buttonIndex - ); // cancel button is button 0
}
} @end
UIAlertView+Blocks.h的更多相关文章
- iOS:简单使用UIAlertVIew和UIActionSheet
做iOS开发的同学想必都用过UIAlertVIew或者UIActionSheet.UIAlertVIew 可以弹出一个出现在屏幕中间的提示视图,给用户展示信息,并让用户自己选择操作,UIActionS ...
- ios开发 <AppName>-Prefix.pch文件的用法详解
我们知道,每新建立一个工程,比如说HelloWord,在分类SupportingFiles里都会有一个以工程名开头-Prefix.pch结尾的文件,如HelloWord-Prefix.pch.对于这个 ...
- IOS之表视图单元格删除、移动及插入
1.实现单元格的删除,实现效果如下 - (void)viewDidLoad { [super viewDidLoad]; //设置导航栏 self.editButtonItem.title = @&q ...
- Objective-C Runtime之着魔的UIAlertView
前言: 上篇文章写的是Runtime的一个入门教程,刚哥问我那个Associated Objects加回调是啥时候用,那我就来告诉你啦!我们在使用UIAlertView的时候用的多. 传统的UIAle ...
- 防止多个UIAlertView重叠弹出
http://www.jianshu.com/p/7ac398ef4532 项目中可能会遇到这种情况,好几个alertView因为逻辑关系全部弹出,用户需要一个个的点击才能将所有的alertView取 ...
- (转载)iOS Framework: Introducing MKNetworkKit
This article is available in Serbo-Croatian, Japanese and German. (Translations in Serbo-Croatian b ...
- BlocksKit的使用
一.引言 众所周知Block已被广泛用于iOS编程.它们通常被用作可并发执行的逻辑单元的封装,或者作为事件触发的回调.Block比传统回调函数有2点优势: 允许在调用点上下文书写执行逻辑,不用分离函数 ...
- ZFPlayer 源码解读
源码下载地址:https://github.com/renzifeng/ZFPlayer 之前自己实现过一个模仿百思不得姐的demo https://github.com/agelessman/FFm ...
- iOS开发常见BUG和一些小技巧(ps:耐心看完,很实用)
[385][scrollView不接受点击事件,是因为事件传递失败] // // MyScrollView.m // Created by beyond on 15/6/6. // Copyright ...
随机推荐
- datagrid数据网格获取所有选中行的索引,插入某个列值为其他列的运算值
获取所有选中行的索引,存入数组ary中: var data=$("#dg").datagrid("getSelections"); var ary=[]; fo ...
- MySQL 导出一句话
听说是很老的东西了,学习的时候发现还是很好用的,故学习转载过来,留备学习. mysql 导出一句话 方法1:网上流行的方法 流程:(1)建表--->(2)插入数据--->(3)select ...
- Codeforces Round #318 (Div. 2) B Bear and Three Musketeers (暴力)
算一下复杂度.发现可以直接暴.对于u枚举a和b,判断一下是否连边,更新答案. #include<bits/stdc++.h> using namespace std; int n,m; ; ...
- UVA1660 Cable TV Network (无向图的点连通度)
题意:求一个无向图的点连通度. 把一个点拆成一个入点和一个出点,之间连一条容量为1的有向边,表示能被用一次.最大流求最小割即可. 一些细节的东西:1.源点固定,汇点要枚举一遍,因为最小割割断以后会形成 ...
- 简单shell执行脚本
#!/bin/bash source /etc/profile APPLICATIONS_HOME="/opt/cpic_analy" APPLICATION_NAME=" ...
- iPhone Tutorials
http://www.raywenderlich.com/tutorials This site contains a ton of fun written tutorials – so many t ...
- 作用域插槽 向父组件传递 <template slot-scope="{ row, index }" slot="dateNo">
作用域插槽 向父组件传递 <template slot-scope="{ row, index }" slot="dateNo"> slotTes ...
- 【414】Code::Blocks增加主题
替换文件地址:C:\Users\z5194293\AppData\Roaming\CodeBlocks 文件下载地址:default.rar 通过 Settings -> Editor... - ...
- 关于jQuery中的$发生冲突及解决方案
问题描述: 在Jquery库中,$是JQuery的别名,所有使用$的地方也都可以使用JQuery来替换,如$('#msg')等同于JQuery('#msg')的写法. 当引入多个js库后,其它的js库 ...
- Ukulele 常用和弦