//
// ViewController.h
// UI5_UIAlertView与UIActionSheet
//
// Created by zhangxueming on 15/7/7.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIAlertViewDelegate,UIActionSheetDelegate> @end //
// ViewController.m
// UI5_UIAlertView与UIActionSheet
//
// Created by zhangxueming on 15/7/7.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSArray *titles =@[@"alert", @"action"];
for (int i=0; i<2; i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(100, 200+i*100, self.view.frame.size.width-200,50); [btn setTitle:titles[i] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
btn.titleLabel.font = [UIFont boldSystemFontOfSize:24];
btn.tag= 100+i;
[self.view addSubview:btn];
}
} - (void)btnClicked:(UIButton *)btn
{
if (btn.tag==100) {
//alert
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"余额不足" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",@"充值", nil];
[alert show];
}
else if (btn.tag == 101)
{
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"分享" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"新浪微博" otherButtonTitles:@"QQ",@"微信",@"陌陌", nil];
[sheet showInView:self.view];
}
} - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"index = %li", buttonIndex);
} - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"index = %li", buttonIndex);
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

UI5_UIAlertView与UIActionSheet的更多相关文章

  1. 弹框控件 UIAlertView UIActionSheet

    // 创建弹框 从底部弹出,一般用于危险操作 UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"恭喜通关" ...

  2. UI第十三节——UIActionSheet

    - (void)viewDidLoad {    [super viewDidLoad];        UISwitch *swc = [[UISwitch alloc] initWithFrame ...

  3. 【代码笔记】iOS-清除图片缓存UIActionSheet

    一,效果图. 二,代码. RootViewController.m //点击任何处出现sheet -(void)touchesBegan:(NSSet *)touches withEvent:(UIE ...

  4. UIAlertView 与 UIActionSheet (提示用户)的使用方法

    UIAlertView 提示用户  帮助用户选择框 //    UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"警 ...

  5. UI里的UIActionSheet按钮

    1.效果图:分别为有短信分享                                      无短信分享 -(void)viewDidLoad{ //添加按钮 UIButton *share ...

  6. UIActionSheet的使用

    UIActionSheet是在iOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件. 为了快速完成这例子,我们打开Xcode 4.3.2, 先建立一个single view applicatio ...

  7. UIAlertView、 UIActionSheet

    一.UIAlertView. UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlert ...

  8. IOS笔记之UIKit_UIAlertView、UIActionSheet

    //首先必须继承协议 @interface TRViewController : UIViewController<UIAlertViewDelegate,UIActionSheetDelega ...

  9. UIActionSheet 修改字体颜色

    -(void)willPresentActionSheet:(UIActionSheet *)actionSheet { SEL selector = NSSelectorFromString(@&q ...

随机推荐

  1. Circle-Progress-View

    https://github.com/jakob-grabner/Circle-Progress-View

  2. Android 和 PHP 之间进行数据加密传输

    Android 和 PHP 之间进行数据加密传输 [代码] [Java]代码 1 mcrypt = new MCrypt(); 2 /* Encrypt */ 3 String encrypted = ...

  3. TP复习3

    ## ThinkPHP 3.1.2 CURD特性#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲: 一.ThinkPHP 3 的CURD介绍 (了解) 二. ...

  4. iOS开发——UI篇Swift篇&UIProgressView

    UIProgressView override func viewDidLoad() { super.viewDidLoad() titleLabel.text = titleString // Do ...

  5. Flex+Struts2+JSON实现Flex和后台的HTTP Service请求

    http://www.fengfly.com/plus/view-191093-1.html Flex+Struts2+JSON的后台代码我在这就不多说了.不懂得请看我写的上一篇文章<Strut ...

  6. 自增锁ID复用问题

    mysql> select * from pp; +----+------+ | id | name | +----+------+ | xx | | xx | | xx | | xx | | ...

  7. 《转》Java中HashMap详解

    HashMap 和 HashSet 是 Java Collection Framework 的两个重要成员,其中 HashMap 是 Map 接口的常用实现类,HashSet 是 Set 接口的常用实 ...

  8. jQuery刷新div内容,并对刷新后元素绑定事件。$(document).on()

    给id=zt的元素绑定点击事件 点击刷新id=ps_list中类容(内容中含有id=zt元素) 把zt的点击事件委托到了document上,这样就不用考虑事件是否能绑定到新加元素上 代码如下: $(d ...

  9. Android Studio常用快捷键汇总(mac)

    查看原文:http://blog.csdn.net/u010818425/article/details/52266195 mac上按键符号 ⌥ : option / alt ⇧ : shift ⌃ ...

  10. iOS - UI - UIWebView

    1.UIWebView UIWebView 是 苹果提供的用来展示网页的UI控件.它也是最占内存的控件. iOS8.0 webkit框架. WKWebView,相比UIWebView,节省了1/3~1 ...