如何確定取消按鈕是否在UIActionSheet上按下?取消按鈕和UIActionSheet的問題
我UIActionSheet設置是這樣的:
-(IBAction)fileButtonPressed
{
UIActionSheet *mymenu = [[UIActionSheet alloc]
initWithTitle:@"Select Folder"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil];
for (i=0; i<3; i++)
{
[mymenu addButtonWithTitle:@"Button Name"];
}
[mymenu showInView:self.view];
}
我已經是我無法取消按鈕和選擇的第一個按鈕區分的問題。
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *option = [actionSheet buttonTitleAtIndex:buttonIndex];
//buttonIndex == 0 if the cancel button is pressed or
//if the first item is pressed.
}
有沒有更好的設置方法?
非常好,謝謝 – shannoga 2013-10-30 15:19:54
UIActionSheet必須是所有iOS中最繁瑣的一段代碼 – bugfixr 2014-02-17 13:04:20