[翻译] STAlertView
STAlertView
The idea of this component is to improve the readability while using the native UIAlertView. The UIKit alert view works with delegates. When you have two or more alerts at the same controller, it becomes a problem because you have to use the TAG to identify from which UIAlertView comes the user.
设计这个控件的目的是为了增强系统原生UIAlertView的可用性,UIKit的alert view是用代理的方式工作的。当你在一个控制器中有着两个或更多个alert时,问题来了(学挖掘机哪家强-_-|||),你需要用TAG值来标示不同的UIAlertView。
With STAlertView you will be able to define the behavior of the 'Ok' and 'Cancel' button, at the same place where you declare the alert view. So, let's see some code:
使用STAlertView的话,在block中标示就行了。
[[STAlertView alloc] initWithTitle:@"Title"
message:@"Message"
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok"
cancelButtonBlock:^{
NSLog(@"do something at cancel"); } otherButtonBlock:^{
NSLog(@"do something at ok"); }];
And that's it, no pieces of code everywhere, just a few lines and all the related code together. As it is a native UIAlertView, the result of using STAlertView is like the native one:
就这些,你不用在其他地方写代码了,仅仅几行代码就行了。
This component has been made thanks to the answer of Ricky Helgesson at StackOverflow.
设计这个组件归功于StackOverflow上的Ricky Helgesson所提供的答案。
Demo usage
To run the example project, clone the repo, and run pod install
from the Example directory first.
为了运行demo,复制repo,运行pod,安装即可
Requirements
Is compatible with ARC and non-ARC.
兼容ARC和non-ARC
Installation
STAlertView is available through CocoaPods. To install it, simply add the following line to your Podfile:
STAlertView支持CocoaPods,使用下面的Podfile即可:
pod "STAlertView"
Then at the view controller that you want to show the alert view add at the .h:
在你需要显示的控制器里面,添加头文件即可:
#import <STAlertView/STAlertView.h>
...
@property (nonatomic, strong) STAlertView *alertView;
...
@end
And at the .m:
...
self.alertView = [[STAlertView alloc] initWithTitle:@"Title of the alert"
message:@"Message you want to show"
cancelButtonTitle:@"No" otherButtonTitles:@"Yes"
cancelButtonBlock:^{
// Code todo when the user cancel
...
} otherButtonBlock:^{
// Code todo when the user accept
...
}];
...
[翻译] STAlertView的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- protocol buffers生成go代码原理
本文描述了protocol buffers使用.proto文件生成pb.go文件的过程 编译器 编译器需要插件来编译环境,使用如下方式安装插件:go get github.com/golang/pro ...
- springboot-3-其他配置
1, 热部署: 有jrebel的话, 不用了, 不如jre好用 原理: 使用两个classLoad, 一个加载不改变的jar, 另一个加载可更改的jar, 发生改变后, 舍弃可更改的jar重新rest ...
- mongodb中Gson和java##Bean对象转化类
此类使用感觉比较繁琐, 每个字段加注解才可以使用, 不如mongoTemplate使用方便, 但如果使用mongo客户端的话, 还是比手动拼接快一点, 所以贴在这儿 package com.iwher ...
- Java序列化机制和原理
Java序列化算法透析 Serialization(序列化)是一种将对象以一连串的字节描述的过程:反序列化deserialization是一种将这些字节重建成一个对象的过程.Java序列化API提供一 ...
- UML——六大关系整理
UML——六大关系整理 1.定义 是一种面向对象的建模语言,它是运用统一的.标准化的标记和定义实现对软件系统进行面向对象的描述和建模(百度百科). 2.六种关系 这六种关系分别为,继承.实现.关联.聚 ...
- VS中调试查看DataTable和DataSet时未能加载此自定义查看器解决方法
在网上找了几个方法,感觉不太实用,最后自己找到了问题所在 VS2017中选择调试-选项-常规中的使用托管兼容模式取消勾选.之后就可以了
- 用fullPage来实现全屏滚动效果
[注意]所有的page要用div包裹,id为fullpage.不能直接包在body中 [使用fullpage的步骤] 1.导入 JQuery.js,fullpage.js,fullpage.css ...
- Java基础之Object类
类Object是类层次结构的根类.每个类都直接或者间接地继承Object类.所有对象(包括数组)都实现这个类的方法.Object类中的构造方法只有一个,并且是无参构造方法,这说明每个类中默认的无参构造 ...
- 百度AI人脸识别的学习总结
本文主要分以下几个模块进行总结分析 项目要求:运用百度AI(人脸识别)通过本地与外网之间的信息交互(MQService),从而通过刷脸实现登陆.签字.会议签到等: 1.准备工作: 内网:单击事件按钮— ...
- 【原】Maven解决Jar包冲突
一.起源 引入二方jar maven 包后出现 NoSuchMethodError org.apache.commons.lang3.StringUtils.isNoneEmpty . 第一感觉就是j ...