ObjectiveCとiPhoneの開発は初めてです。アクションシート内にアクションシートを追加する方法を教えてください。ボタンをタップするとアクションシートが開き、アクションの最初のButtonIndexをクリックすると、別のアクションシートが表示されます。完全なコードについて言及してください。ありがとう
2 に答える
1
UIActionSheet
デリゲート メソッドを使用します。
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) { // Add an action sheet for one of these buttons -> maybe here if you want...
NSLog(@"You clicked the first button...");
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Another action sheet"
delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive"
otherButtonTitles:@"Other Button 1", nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery showInView:self.view];
[popupQuery release];
}
else {
NSLog(@"Dismissing action sheet");
}
}
于 2012-08-07T18:34:35.473 に答える
0
最初の UIActionSheet を閉じて、その場所に別の UIActionSheet を表示するだけです。つまり、別の UIActionSheet内に UIActionSheet を表示するのではなく、別の UIActionSheet が閉じられた後に UIActionSheet を表示する必要があります。
アクション シートがいつ閉じられるかを調べるには、 UIActionSheetDelegateプロトコルを実装する必要があります。例えば:
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
// first action sheet is dismissed
// show a new action sheet here
}
于 2012-08-07T18:40:47.887 に答える