gpt4 book ai didi

iphone - 更改 UIAlertView 中取消按钮的位置?

转载 作者:技术小花猫 更新时间:2023-10-29 10:28:44 28 4
gpt4 key购买 nike

我注意到,当我从 iPhone 主屏幕上删除应用程序时,出现的警报 View 在左侧显示删除按钮,在右侧显示取消按钮。但是,当我使用 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;

这会将“删除”按钮放在左侧,将“取消”按钮放在右侧,并突出显示“取消”按钮。

关于iphone - 更改 UIAlertView 中取消按钮的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4456675/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com