UIAlertView自定义中的iOS 7 UIDatePicker

Sat*_*ran 2 uidatepicker uialertview ios ios7

伙计们,我将到的UIDatePicker UIAlertView中像这样

在此输入图像描述

iOS 6及以下版本在iOS 7中很好用,就像这样

在此输入图像描述

任何想法为什么会这样?有没有更好的方法来做到这一点?.感谢任何帮助.

mal*_*lex 8

您可以更改accessoryView的任何自己customContentView在iOS7标准警报视图

[alertView setValue:customContentView forKey:@"accessoryView"];
Run Code Online (Sandbox Code Playgroud)

请注意,您必须在[alertView show]之前调用它.

最简单的说明示例:

UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"TEST" message:@"subview" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
v.backgroundColor = [UIColor yellowColor];
[av setValue:v forKey:@"accessoryView"];
[av show];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

完全按照相同的方式添加DatePicker.