arl*_*dia 12 iphone hig uialertview ios4 ios
我注意到当我从iPhone主屏幕删除某个应用程序时,出现的警报视图会在左侧显示"删除"按钮,在右侧显示"取消".但是,当我使用UIAlertView在我的应用程序中构建删除功能时,按钮似乎只显示左侧的取消和右侧的删除.
我希望我的应用程序与操作系统保持一致,但我无法弄清楚如何首先显示"取消"按钮.有人知道吗?
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Delete Song"
message:@"Are you sure you want to delete this song? This will permanently remove it from your database."
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Delete", nil];
Run Code Online (Sandbox Code Playgroud)
我尝试设置alert.cancelButtonIndex = 1,但这没有任何效果.
arl*_*dia 52
啊,我刚想出如何改变这一点.cancelButtonTitle参数是可选的,因此您可以在任何您想要的位置添加自定义按钮,然后将其指定为取消按钮,如下所示:
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Delete Song"
message:@"Are you sure you want to delete this song? This will permanently remove it from your database."
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Delete", @"Cancel", nil];
alert.cancelButtonIndex = 1;
Run Code Online (Sandbox Code Playgroud)
这会将"删除"按钮放在左侧,将"取消"按钮放在右侧,并突出显示"取消"按钮.
苹果在主屏幕上使用警报视图的一个可能原因是它曾经要求用户对他们要删除的应用程序进行评分(不再是了)。他们可能将“取消”按钮设为浅色,因为这被认为是一种破坏性操作(删除应用程序及其数据)。
我想你可以颠倒标题 ( cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel", nil
) 并以相反的方式处理这些按钮的点击(不确定 Apple 是否也这样做)。但这会有点尴尬;使用操作表怎么样?
归档时间: |
|
查看次数: |
10722 次 |
最近记录: |