是的,但是我有一个问题我创建了一个继承自uitableviewcontroller的控制器,我编写了一个代码,在工具栏上的barbutton项目上调用了动作表,但它给了我一个错误。
mapType = [[[UIBarButtonItem alloc]initWithTitle:@"MAP TYPE" style:UIBarButtonItemStyleBordered target:self action:@selector(chooseMapType:)]autorelease];
self.toolbarItems = [NSArray arrayWithObjects:space, addButton, removeButton,mapType, nil]; [self.navigationController.view addSubview:self.navigationController.toolbar];
- (IBAction)chooseMapType:(id)sender {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Map Type" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:kMapTypeRegular, kMapTypeSatellite, nil];
[sheet showFromToolbar:navigationController.toolbar];
[sheet release];
}
这是我传递给选择器的方法。
- (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *clickedButtonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];
if ([clickedButtonTitle isEqualToString:kMapTypeRegular])
[[self mapView] setMapType:MKMapTypeStandard];
else if ([clickedButtonTitle isEqualToString:kMapTypeSatellite])
[[self mapView] setMapType:MKMapTypeSatellite];
}
这是我的动作表方法,但它没有被调用并给我一个错误 - [UIActionSheet _presentSheetFromView:above:],/ SourceCache / UIKit_Sim / UIKit-1447.6.4 / UIActionSheet。 - Abhishek 3月24日8:59
答案 0 :(得分:0)
请确保您的 chooseMapType 功能与XIB文件中的 UIBarButtonItem 正确连接。