zoukankan      html  css  js  c++  java
  • iOS.UIKit.07.UIAlertView_UIActionSheet

    一、案例介绍:点击第一个按钮弹出提示框;点击第二个按钮弹出操作表。如图01,图02,图03

    图01图02图03

    二、案例步骤:

    1、选择Simple View Aplication,取名cq.32.警告框和操作表,如图04

    2、Main.storyboard

    3、CQ32ViewController.h

    #import <UIKit/UIKit.h>
    
    @interface CQ32ViewController : UIViewController<UIAlertViewDelegate,UIActionSheetDelegate>
    
    - (IBAction)testAlertView:(id)sender;
    - (IBAction)testActionSheet:(id)sender;
    
    @end

    4、CQ32ViewController.m

    - (IBAction)testAlertView:(id)sender
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Alert text goes here" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
        [alertView show];
    }
    #pragma mark -- 实现UIAlertViewDelegate
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        NSLog(@"buttonIndex = %i",buttonIndex);
    }
    
    - (IBAction)testActionSheet:(id)sender
    {
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"破坏性按钮" otherButtonTitles:@"新浪微博", nil];
        actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
        [actionSheet showInView:self.view];
    }
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        NSLog(@"buttonIndex = %i",buttonIndex);
    }
  • 相关阅读:
    七周七语言——Prolog(二)
    centos中使用python遇到的几个问题
    use SWF / Flash in cocos2d-x; cocos2d(cocos2d-x) 直接播放flash / SWF文件
    【C++自我精讲】基础系列二 const
    Find发帖水王哥
    JAVA从零单排之前因
    CSharp
    python实战--Http代理服务器
    有道单词-批量导入[只有单词]
    编译原理(一道小证明题)
  • 原文地址:https://www.cnblogs.com/cqchen/p/3764930.html
Copyright © 2011-2022 走看看