2011-03-28 10 views
0

はい、問題があります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:上記:]、/SourceCache/UIKit_Sim/UIKit-1447.6.4/UIActionSheet。 - アビシェーク8時59分

答えて

0

で3月24日を確認してください、あなたのchooseMapType機能が正しくXIBファイルでUIBarButtonItemに接続されています。

+0

xibに正しく接続されています。 – Rocky

関連する問題