我注意到,当我从 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];
我尝试设置alert.cancelButtonIndex = 1,但这没有效果。
啊,我刚刚想出了如何改变这一点。 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;
这会将“删除”按钮放在左侧,将“取消”按钮放在右侧,并突出显示“取消”按钮。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)