ios - iOS 8 上的 UIAlertController/UIAlertView 滚动

标签 ios objective-c

我想知道是否有人知道 UIAlertViews 和 UIAlertControllers 不会在 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 8:

iOS 7:
iOS 7:

如您所见,它在 iOS 7 上可以清楚地滚动,但在 iOS 8 上则不能。是否有某些我在这里遗漏的属性,或者它只是一个测试版错误?

最佳答案

虽然我不知道正确的方法,但我还是可以解决问题。 如果设置框架属性(但不是 CGRectZero), View 似乎会滚动。 它在 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 - iOS 8 上的 UIAlertController/UIAlertView 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24671833/

相关文章:

ios - IOS核心数据。是否可以在不获取数据的情况下查看已保存的数据

ios - 如何打印来自简单有效的 POST 方法的响应

objective-c - UIScrollView,下拉效果类似CalcBot

objective-c - 一般学习 Objective-C 和 Xcode 时注意到的好奇心

objective-c - quickDialog 表单的通用类

iOS requestAccessToAccountsWithType 不显示权限提示/NSAlert

ios - Swift - 当 AVPlayer 在后台模式下被覆盖时如何发送通知?

ios - NSInvalidArgumentException -[__NSCFString unsignedLongLongValue] : unrecognized selector sent to instance

android - 在 iPhone 和 Android 上流式传输的最佳音频文件格式是什么

iphone - 以编程方式将图像粘贴到图像上