使用Alert中的子视图未记录 [英] Is using subviews in Alert undocumented

查看:104
本文介绍了使用Alert中的子视图未记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在,他们说如下:


虽然您可以选择要在警报中放置的
按钮的数量,但
双按钮警报通常是最有用的
,因为
用户最容易在两个
替代品之间进行选择。使用单个
按钮显示警报几乎不是一个好主意
,因为这样的警报不能
给予用户对
情况的任何控制权;相反,它只能
显示信息并提供
关闭按钮。 包含
三个或更多按钮的警报比双按钮警报更加复杂

,如果可能,应该避免。

事实上,如果您发现需要
为用户提供两个以上的选择,那么
应该考虑使用行动表
(参见使用行动表和
设计行动表有关此类视图的更多
信息。



因为用户有时会在不仔细阅读的情况下回复
提醒,
一定要提供适当的
默认选择。为了帮助引导
不专心的用户选择这个选项,
使浅色右手
按钮成为安全,默认的替代方案。

例如,你可能会选择将
这个按钮设为取消按钮,以帮助
用户避免无意中造成
危险行为,或者你可以将
代表最常见的响应,如果
结果操作不是
破坏性。



以下指南描述了如何在警报中配置
按钮:




  • 在带有两个按钮的提醒中,左边的按钮总是
    深色,而
    右边的按钮从不是暗色的。


  • 在提示潜在风险行为的双按钮警报中,取消操作的按钮
    应该是开启的
    右边和浅色。


  • 在一个提示良性动作的双按钮警报中,
    的按钮可以cels动作应该在
    左边(因此是深色的)。


  • 在带有单个按钮的警报中,按钮是浅色的。


您明显违反了按钮大小,形状,数量和颜色的指导原则您的警报视图(红色具有非常明确的意义,作为破坏性操作,而不是确认)。即使Apple没有拒绝您的审核申请(他们倾向于明确违反人机界面指南),这对您的用户来说也会非常混乱。



此外,导航任何Apple提供的用户界面元素的隐藏视图层次结构是一种非常糟糕的做法。视图层次结构未记录,并且经常更改。当人们升级到iPhone OS 3.0时,许多应用程序开始崩溃,因为这些应用程序通过UI元素的子视图做了一些时髦的事情,并且这些元素在新操作系统版本中发生了变化。 Apple甚至在iPhone OS 3.0迁移文档(我现在找不到)中特别指出了这一点。



由于这引起的问题,他们似乎已经破解了这种做法,并因此拒绝了申请。即使他们不这样做,如果你这样做也会蔑视你的用户,因为这意味着你不关心你的应用程序是否会因未来的操作系统升级而中断。


I have asked a similar question here and got some answers, so first of all sorry for making you people bother once again.

But I have an argument this time. First I will show my piece of code

- (void) showTheAlert{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hey!" message:@"?" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Yes",@"No",@"Don't know eaxactly.",nil];
    [alertView setTag:101];
    [alertView show];
}

- (void)willPresentAlertView:(UIAlertView *)alertView{
    if(alertView.tag == 101){
        [[[alertView subviews] objectAtIndex:2] setBackgroundColor:[UIColor colorWithRed:0.5 green:0.0f blue:0.0f alpha:0.5f]];
        [[[alertView subviews] objectAtIndex:3] setBackgroundColor:[UIColor colorWithRed:0.0 green:0.5f blue:0.0f alpha:0.5f]];
    }

}

And my final alert looks like

Now my confusion is that, [alertView subviews] is not documented as some people may say but alertview is a subclass of UIView, which has a property called subviews.

So I am using the documented property of a superclass which is definitely allowed.

So if this alertview may cause rejection of my app or not? ( I don't think apple will have any base to say I am using the undocumented or a private api. The look and feel is also alike to alertview.)

解决方案

To follow on Henrik's reply, in the iPhone Human Interface Guidelines section "Designing an Alert", they say the following:

Although you can choose the number of buttons to place in an alert, a two-button alert is often the most useful, because it is easiest for users to choose between two alternatives. It is rarely a good idea to display an alert with a single button because such an alert cannot give users any control over the situation; instead, it can only display information and provide a dismiss button. An alert that contains three or more buttons is significantly more complex than a two-button alert, and should be avoided if possible. In fact, if you find that you need to offer users more than two choices, you should consider using an action sheet instead (see "Using Action Sheets" and "Designing an Action Sheet" for more information on this type of view).

Because users sometimes respond to alerts without reading them carefully, be sure to provide an appropriate default choice. To help guide inattentive users towards this choice, make the light-colored, right-hand button the safe, default alternative. For example, you might choose to make this button the Cancel button, to help users avoid inadvertently causing a dangerous action, or you might make it represent the most common response, if the resulting action isn’t destructive.

The following guidelines describe how buttons are configured in an alert:

  • In an alert with two buttons, the button on the left is always dark-colored and the button on the right is never dark-colored.

  • In a two-button alert that proposes a potentially risky action, the button that cancels the action should be on the right and light-colored.

  • In a two-button alert that proposes a benign action, the button that cancels the action should be on the left (and therefore dark-colored).

  • In an alert with a single button, the button is light-colored.

You are clearly violating the guidelines in size, shape, number, and color of the buttons in your alert view (red has a very clear meaning as a destructive action, not a confirmation). Even if Apple doesn't reject your application in review (which they tend to do for clear violations of the Human Interface Guidelines), this would be extremely confusing to your users.

Also, navigating the hidden view hierarchy for any Apple-supplied user interface element is a very bad practice. The view hierarchies are undocumented, and do change often. Many of the applications that started crashing when people upgraded to iPhone OS 3.0 did so because those applications did something funky with subviews of UI elements, and those elements changed in the new OS version. Apple even specifically called this out in the iPhone OS 3.0 migration documents (which I can't find now).

Because of the problems this caused, they appear to have cracked down on this practice and have been rejecting applications because of it. Even if they don't, it shows contempt for your users if you do this, because it means that you don't care if your application breaks with future OS upgrade.

这篇关于使用Alert中的子视图未记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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