我一直在嘗試這一個今晚一段時間....我有一個UIActionSheet在它自己的控制器。我在導入控制器的視圖中,我希望它被顯示。我無法弄清楚當用戶按下其中一個按鈕時,如何顯示一個新的視圖(您可以看到我現在只發送一個警報的位置)。有任何想法嗎?UIActionSheet Button加載一個新視圖
- (void)helpButtonPressedView {
// open a dialog with two custom buttons
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@""
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
otherButtonTitles:@"Help", @"Credits", nil];
[self parentViewController];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view]; // show from our table view (pops up in the middle of the table)
[actionSheet release];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"Button Pressed: %d",buttonIndex);
int btn = buttonIndex;
UIAlertView *alert;
switch (btn) {
case 0:
// help screen
alert = [[UIAlertView alloc] initWithTitle:@"Button Press Notice" message:@"The Help screen will be dispayed"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
// helpViewController = [[HelpViewController alloc] init];
// [self presentModalViewController:helpViewController animated:YES];
break;
case 1:
// credits screen
alert = [[UIAlertView alloc] initWithTitle:@"Button Press Notice" message:@"The Credits screen will be dispayed"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
break;
default:
break;
}
}
這是我正在嘗試做的事情的照片......當用戶按下「幫助」按鈕時,顯示一個新的視圖。當用戶按下「Credits」按鈕時會顯示不同的視圖。我正在使用IB來創建視圖。
如果您稍微解釋一下您試圖在視覺上做什麼,這將會有所幫助。 – 2009-07-17 05:05:09