我想知道有没有人知道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上工作正常.
如果您设置了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{};