iphone开发 UIActionSheet(操作表) 和UIAlertView(警告)的用法

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-02 06:15 点击:

一.UIActionSheet(操作表) 和UIAlertView(警告)
 
UIActionSheet用于迫使用户在两个或更多的选项之间进行选择的模式视图。操作表从屏幕底部弹出,显示一系列按钮供用户选择,用户只有单击一个按钮后才能继续使用应用程序。
UIAlertView警告以蓝色圆角矩形形式出现在屏幕中部,警报可显示一个或多个按钮
为了让控制器类充当操作表的委托,控制器需要遵从UIActionSheetDelegate协议
 
二.UIActionSheet(操作表)的创建
 
initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:
 
注释:initWithTitle是对象函数
            initWithTitle:操作表标题
            delegate:接收对象
     cancelButtonTitle关闭按钮标题
            destructiveButtonTitle: 操作按钮标题
            otherButtonTitles:其他按钮
 
1.   创建一个简单的操作表:
    //open a dialog with an OK and cancel button
    UIActionSheet*actionSheet = [[UIActionSheet alloc] 
                  initWithTitle:@" UIActionSheet<title>"
                   delegate:self  
                  cancelButtonTitle:@"Cancel"
                  destructiveButtonTitle:@"OK"
                    otherButtonTitles:nil];
 
    actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
 
    [actionSheetshowInView:self.view]; //show from our table view (pops up in the middle of the table)
 
    [actionSheetrelease];

\

2.    创建两个按钮的操作表

            // open a dialog with an OKand cancel button

    UIActionSheet*actionSheet = [[UIActionSheet alloc]

                   initWithTitle:@" UIActionSheet<title>"

                    delegate:self

                   cancelButtonTitle:@"Cancel"

                    destructiveButtonTitle:@"OK"

                   otherButtonTitles:nil];

 

    actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

    [actionSheetshowInView:self.view]; //show from our table view (pops up in the middle of the table)

    [actionSheetrelease];

 \

3.   创建自定义操作表:

 

    //open a dialog with two custom buttons

    UIActionSheet*actionSheet = [[UIActionSheet alloc]

        &nbs

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • Lexical or Preprocessor Issue 'xxx.h
      • ios学习笔记(二)xcode 4.3.2下实现基本交互
      • ios版本的helloworld
      • iphone(object-c) 内存管理(3) 有效的内存管理 前半部分
      • ios学习笔记(一)xcode 4.3.2下创建第一个ios项目
      • IOS类似iphone通讯录TableView的完整demo【附源码】
      • UITableView一些方法
      • [iPhone中级]iPhone团购信息客户端的开发 (二)
      • 如何为Iphone应用创建启动界面
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1