我经常在iphone应用程序中看到类似底部图片的东西,并且想知道是否有标准的方法来实现这一点。如何在iPhone UI中提供替代选项?
要清楚,它是一个视图,覆盖了一半的屏幕,通常用按钮来选择不同的选项。当我要求标准的方式,我的意思的UITableView,UIAlertView中,UIScrollView的,等等
我经常在iphone应用程序中看到类似底部图片的东西,并且想知道是否有标准的方法来实现这一点。如何在iPhone UI中提供替代选项?
要清楚,它是一个视图,覆盖了一半的屏幕,通常用按钮来选择不同的选项。当我要求标准的方式,我的意思的UITableView,UIAlertView中,UIScrollView的,等等
是的,它被称为UIActionSheet。这里有一个例子:
UIActionSheet *takeAction = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Delete"
otherButtonTitles:@"New...", @"Open...", @"Save As...", nil];
[takeAction setActionSheetStyle:UIActionSheetStyleDefault];
// use this to implement it with a tabBarController; similar ways to work with navBars
[takeAction showFromTabBar:(UITabBar *)[[self tabBarController] view]];
[takeAction release];
与一个alertView,你的按钮响应与
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == [actionSheet destructiveButtonIndex]) {
[self deleteIt];
} else if (buttonIndex == [actionSheet cancelButtonIndex]) {
} else if (buttonIndex == 1) {
[self createNew];
} else if (buttonIndex == 2) {
[self openSaved];
} else if (buttonIndex == 3) {
[self saveAs];
} else {
}
}
此外,确保申报的viewController是委托:
<UIActionSheetDelegate>
您正在寻找UIActionSheet:http://developer.apple.com/library/ios/documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html
使用这些(或任何其他UI之前元素)也会检查iOS人机界面指南中关于如何使用它们的说法。我经常看到行为表被滥用,可悲的是。
甜头。谢谢。我会确定试试看tmrw! – okysabeni 2011-03-11 04:56:48