所以我完全在类的名称上画了一个空白,该类用多个选项绘制其中一个模态提示。我附上了截图。这是确认用户是否想要退出的提示。
答案 0 :(得分:3)
这是UIActionSheet
,请阅读UIActionSheet Class Reference。
在标题中,您需要添加<UIActionSheetDelegate>
协议。然后在您的@implementation
中,您将如何称呼此特定工作表:
UIActionSheet * sampleSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure you'd like to sign out from Path?" delegate:self
cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Sign Out" otherButtonTitles:nil];
[sampleSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[sampleSheet showInView:self.view];
这就是你处理工作表的方式:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch ( buttonIndex )
{
case 0:
NSLog(@"User Chose Cancel");
break;
case 1:
NSLog(@"User Chose to Sign out.");
break;
}
}
答案 1 :(得分:0)
答案 2 :(得分:0)
请参阅UIActionSheet,我认为这是您正在寻找的课程。
答案 3 :(得分:0)
UIActionSheet *popupQuery;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//give the user an option to choose an image from their library or take a new photo...
popupQuery = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose From Library", nil];
popupQuery.tag = 0;
}
else {
//give the user an option to choose an image from their library or take a new photo...
popupQuery = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Choose From Library", nil];
popupQuery.tag = 1;
}
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery showInView:[self.view window]];
[popupQuery release];