objective-c - 在警报中使用 subview 未记录

标签 objective-c iphone

我问过类似的问题here并得到了一些答案,所以首先很抱歉再次打扰你们。

但是这次我有一个争论。首先我将展示我的代码

- (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]];
    }

}

我的最终警报看起来像

enter image description here

现在我的困惑是,[alertView subviews]正如有些人可能会说的那样,没有记录,但 Alertview 是 UIView 的子类,它有一个名为 subviews 的属性。

所以我正在使用父类(super class)的记录属性,这是绝对允许的。

那么这个警报 View 是否会导致我的应用程序被拒绝? (我认为苹果不会有任何依据说我正在使用未记录的或私有(private)的API。外观和感觉也与alertview相似。)

最佳答案

苹果 iPhone Human Interface Guidelines关于警报 View 明确指出:

The infrequency with which alerts appear helps users take them seriously. Be sure to > minimize the number of alerts your application displays and ensure that each one offers > critical information and useful choices. In general, try to avoid creating alerts that:

  • Update users on tasks that are progressing normally. Instead, consider using a progress view or an activity indicator to provide progress-related feedback to users (these controls are described in “Progress Views” and “Activity Indicators”).

  • Ask for confirmation of user-initiated actions.To get confirmation for an action the user initiated, even a potentially risky action such as deleting a contact, you should use an action sheet (described next in “Using Action Sheets”).

  • Inform users of errors or problems about which they can do nothing. Although it might be necessary to use an alert to tell users about a critical problem they can’t fix, it’s better to integrate such information into the user interface, if possible. For example, instead of telling users every time a server connection fails, display the time of the last successful connection.

所以,我的建议是,等待潜在拒绝的时间不值得你花时间。不要冒险。

关于objective-c - 在警报中使用 subview 未记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2032500/

相关文章:

iphone - UISlider第二次卡住

ios - StoryBoards 从 View Controller 导航到 Tab view controller iOS 5

ios - 右对齐 UISearchbar 占位符

ios - iOS Xcode 中的除法

iphone - 按 Objective C 中的子数组值对数组排序

ios - NSMutableAttributedString 中的 Tab 是什么

iphone - 如何在 iPhone 中绘制可调整大小的多边形?

javascript - 我可以创建调用 Windows Phone 7 silverlight 应用程序的 HTML 5/JS 应用程序吗

ios - 如何在用户键入时创建增加框架大小而不是增加滚动大小的 TextView

objective-c - iOS 中的股票 candleStick 图表?