更改UIAlertView中取消按钮的位置? [英] change position of cancel button in UIAlertView?

查看:113
本文介绍了更改UIAlertView中取消按钮的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到当我从iPhone主屏幕删除应用程序时,出现的警报视图会在左侧显示删除按钮,在右侧显示取消。但是,当我使用UIAlertView在我的应用程序中构建删除功能时,按钮似乎只显示左侧的取消和右侧的删除。

I noticed that when I delete an app from my iPhone home screen, the alert view that appears shows a Delete button on the left and Cancel on the right. However, when I build a delete function within my app using UIAlertView, the buttons only seem to display with Cancel on the left and Delete on the right.

我想要我的应用程序与操作系统保持一致,但我无法弄清楚如何使取消按钮首先出现。有谁知道?

I'd like my app to be consistent with the OS, but I can't figure out how to make the Cancel button appear first. Does anyone know?

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,但这没有效果。

I tried setting alert.cancelButtonIndex = 1, but that had no effect.

推荐答案

Apple在主屏幕上使用警报视图的一个可能原因是因为它曾经要求用户对他们正在删除的应用程序进行评级(不再是)。他们可能会将取消按钮设置为浅色,因为这被视为破坏性操作(删除应用及其数据)。

A possible reason Apple used an alert view on the home screen was because it once asked users to rate the apps they were removing (not anymore). They likely made the Cancel button the lighter-colored one because this was considered a destructive action (deletes an app and its data).

我想你可以撤销标题( cancelButtonTitle:@删除otherButtonTitles:@取消,nil )并反过来处理这些按钮的点击(不确定Apple是否也这样做)。那会有点尴尬;如何使用操作表呢?

I guess you could reverse the titles (cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel", nil) and handle clicks on those buttons the other way around (not sure if Apple did the same). That would be a little awkward though; how about using an action sheet instead?

这篇关于更改UIAlertView中取消按钮的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆