【发布时间】:2012-01-13 23:42:35
【问题描述】:
我有一个带有标准 UIView 的应用程序,其中包含一个工具栏。我可以点击工具栏上的一个按钮来打开 UIActionSheet,并且可以在那里毫无问题地显示我的文本。我想做的是让操作表项目显示与我的项目不同的 XIB。我在相关的头文件和实现文件以及 XIB 中都设置了所有内容,但我需要将点击操作表项的操作链接到显示第二个视图。
这是我目前所拥有的:
- (void)actionSheet:(UIActionSheet *)sheet willDissmissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [sheet cancelButtonIndex]) {
if (buttonIndex == 0) {
ABC *secondview = [[ABC alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:secondview animated:YES];
}
if (buttonIndex == 1) {
DEF *secondview = [[DEF alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:secondview animated:YES];
}
if (buttonIndex == 2) {
GHI *secondview = [[GHI alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:secondview animated:YES];
}
[self dismissModalViewControllerAnimated:YES];
};
}
这会打开我的操作表并显示所有正确信息,但点击“ABC”、“DEF”或“GHI”只会关闭操作表,就像我点击了取消按钮一样。如何设置它以便点击“ABC”、“DEF”或“GHI”在我的项目中打开不同的 XIB?
【问题讨论】: