Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何调用工具栏按钮项上的操作表_Iphone_Objective C - Fatal编程技术网

Iphone 如何调用工具栏按钮项上的操作表

Iphone 如何调用工具栏按钮项上的操作表,iphone,objective-c,Iphone,Objective C,嗨, 我想调用位于底部工具栏上的左栏按钮项上的操作表。如何执行此操作将按钮设置为运行“myButtonPressed”,然后使用代码 - (void)myButtonPressed:(id)sender { UIActionSheet* action = [[UIActionSheet alloc] initWithTitle:@"Menu" delegate:self

嗨,
我想调用位于底部工具栏上的左栏按钮项上的操作表。如何执行此操作

将按钮设置为运行“myButtonPressed”,然后使用代码

- (void)myButtonPressed:(id)sender
{
    UIActionSheet* action = [[UIActionSheet alloc] 
                         initWithTitle:@"Menu" 
                         delegate:self 
                         cancelButtonTitle:@"Continue"
                         destructiveButtonTitle:@"Quit" 
                         otherButtonTitles:@"Debug",nil ];
[action showInView:self.view];
[action release];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:   (NSInteger)buttonIndex {
switch (buttonIndex) {
    case 0: // continue
        NSLog(@"Continue");
        break;
    case 1: // Quit
        NSLog(@"Quit");
        break;
    case 2: // Debug
        NSLog(@"Debug");
        break;
}
}
在.h文件中

@interface ViewController : UIViewController <UIActionSheetDelegate>
@界面ViewController:UIViewController

您的意思是要在单击左栏项目时查看UIActionSheet?是的,但我有一个问题,我创建了一个从uitableviewcontroller继承的控制器,并且我编写了一段代码,调用工具栏上的barbutton项上的操作表,但它给了我一个错误。mapType=[[UIBarButtonItem alloc]initWithTitle:@“映射类型”样式:uiBarbuttonItemStyleBordedTarget:self action:@selector(chooseMapType:)]autorelease];self.toolbarItems=[NSArray arrayWithObjects:space、addButton、removeButton、mapType、nil];[self.navigationController.view addSubview:self.navigationController.toolbar];-(iAction)chooseMapType:(id)发送方{UIActionSheet*sheet=[[UIActionSheet alloc]initWithTitle:@“映射类型”委托:自取消按钮:@“取消”破坏性按钮:无其他按钮:kMapTypeRegular,kMapTypeSatellite,无];[sheet showFromToolbar:navigationController.toolbar];[sheet release];}这是我传递给选择器的方法。-(void)actionSheet:(UIActionSheet*)actionSheet ClickedButtonIndex:(NSInteger)buttonIndex{NSString*clickedButtonTitle=[actionSheet ButtonTitle:buttonIndex];if([clickedButtonTitle IseQualString:KmaptTypeRegular])[[self mapView]setMapType:MKMapTypeStandard];else if([clickedButtonTitle IseQualtString:kMapTypeSatellite])[[self mapView]setMapType:MKMapTypeSatellite];}这是我的操作表方法,但没有被调用,并给我一个错误-[UIActionSheet\u presentSheetFromView:上图:],/SourceCache/UIKit_Sim/UIKit-1447.6.4/UIActionSheet。请您将之前对您的问题的所有评论发表出来,以便更具可读性,我随时准备提供帮助。