UIAlertController / UIAlertView在iOS 8上滚动

前端之家收集整理的这篇文章主要介绍了UIAlertController / UIAlertView在iOS 8上滚动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道有没有人知道UIAlertViews和UIAlertController在iOS 8上不会滚动的事实的一个很好的解决方案?这是一个例子:
[[[UIAlertView alloc] initWithTitle:@"Test" message:@"long string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong
string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\n
long string\nlong string\nlong string\nlong string\nlong string\nlong string\n
long string\nlong string\nlong string\nlong string\nlong string\nlong string\n"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show];

在iOS 7和8上运行该代码会产生以下结果. (将其更改为UIAlertController没有任何区别).

iOS 8:

IOS 7:

你可以看到它清楚地在iOS 7上滚动,但不是在iOS 8上.有没有一些属性,我在这里丢失或只是一个测试版错误

解决方法

虽然我没有正确的方法,但我也可以解决问题.
如果您设置了frame属性(但不是CGRectZero),就像视图滚动一样.
它在iOS 8.0.2上工作正常.
NSString* messageString = @"long string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\nlong string\n";

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title"
                                                                         message:messageString
                                                                  preferredStyle:UIAlertControllerStyleAlert];

alertController.view.frame = [[UIScreen mainScreen] applicationFrame];

[alertController addAction:[UIAlertAction actionWithTitle:@“OK”
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action){
                                                      [self okButtonTapped];
                                                  }]];
[self presentViewController:alertController animated:YES completion:nil];

//——
- (void) okButtonTapped{};

猜你在找的iOS相关文章