我问过类似的问题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]];
}
}
我的最终警报看起来像
现在我的困惑是,[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/