最开始我们学习过关于Alert的一些相关知识,那么我们知道alert是弹出一个警告窗体,可能有一个或多个按钮供用户进行选择,而ActionSheet是底部弹出,有两个及两个以上的选项供用户进行选择。我们今天就来学习一下ActionSheet。
因为这个也不是什么特别的难点,那么我们就在之前写过的项目基础上改写一下:
首先在头文件中添加<UIActionSheetDelegate>
@interface ECViewController : UIViewController<UIActionSheetDelegate>
然后在按钮的点击事件中添加如下的代码:
- (IBAction)loginBtnPress:(UIButton *)sender
{
UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:@"你确定要这么做?" delegate:self cancelButtonTitle:@"好吧,你赢了" destructiveButtonTitle:@"劳资很确定" otherButtonTitles:nil, nil];
[actionSheet showInView:self.view];
}
(PS:有前辈说我这学习速度有些慢了,所以要抓紧一切可利用的时间来学习,嗯,同时也要多向一些前辈讨教下学习心得等)
2013年05月16日,Eric.Tang 记