iOS UIActionSheet_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > iOS UIActionSheet

iOS UIActionSheet

 2013/8/1 23:13:25  火红的云彩  博客园  我要评论(0)
  • 摘要:想要用UIActionSheet必须现在.h文件中加个协议<UIActionSheetDelegate>这时操作表//定义一个操作表-(IBAction)uisheel:(id)sender{UIActionSheet*action=[[UIActionSheetalloc]initWithTitle:@"who!!!"delegate:selfcancelButtonTitle:@"yes"destructiveButtonTitle:@"no"otherButtonTitles
  • 标签:iOS

想要用 UIActionSheet必须现在 .h文件中加个协议  

<UIActionSheetDelegate>

这时操作表

//定义一个操作表
- (IBAction)uisheel:(id)sender {
    UIActionSheet *action=[[UIActionSheet alloc] initWithTitle:@"who!!!" delegate:self cancelButtonTitle:@"yes" destructiveButtonTitle:@"no" otherButtonTitles:@"yes or no", nil];
    
    [action showInView:self.view];
    [action release];
}



//先从一个事件中调用操作表

- (void)actionSheetCancel:(UIActionSheet *)actionSheet
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"actionSheetCancel1 you" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];//声明操作表
    [v show];//执行操作表
    [v release];//释放操作表
}

// Called when a button is clicked. The view will be automatically dismissed after this call returns
//但我们点击操作表按钮时出发的事件
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    //buttonIndex判断我们点击的时那个按钮,我们在设置的第一个的buttonIndex的数字时1,第二个时2.。。。
    if (buttonIndex==0) {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am Number one" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    }
    else if (buttonIndex==1) {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am number Two" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    }
    else {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am number threeth" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    }

}

//Called when a button is clicked. The view will be automatically dismissed after this call returns
//显示视图之前调用
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet // before animation and showing view 1 7
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"第1次和最后一次" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
    [v show];
    [v release];

}
// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.取消视图时调用
// If not defined in the delegate, we simulate a click in the cancel button
//显示视图之后调用
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet;  // after animation 2 6
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"第二次和第6次" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
    [v show];
    [v release];

}
//动画前和隐藏视图前调用
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex
// before animation and hiding view3 5
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"第3次和第5次" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
    [v show];
    [v release];

}
//动画之后调用
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
// after animation 4
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"第4次" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
    [v show];
    [v release];

}

 

 

 

 

上一篇: WCF学习笔记之并发与限流 下一篇: 没有下一篇了!
发表评论
用户名: 匿名