UIAlertController / UIAlertView在iOS 8上滚动 [英] UIAlertController/UIAlertView scrolling on iOS 8

查看:156
本文介绍了UIAlertController / UIAlertView在iOS 8上滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人知道UIAlertViews和UIAlertControllers不会在iOS 8上滚动的好方法?这是一个例子:

I'm wondering if anyone knows a good solution to the fact that UIAlertViews and UIAlertControllers won't scroll on iOS 8? Here is an example:

[[[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没有区别。)

Running that code on iOS 7 and 8 produces the following results. (Changing it to UIAlertController makes no difference).

iOS 8:

iOS 8:

iOS 7:

iOS 7:

正如你所看到的那样,它在iOS 7上清晰滚动但在iOS 8上没有滚动。是有一些我在这里失踪的属性还是只是一个测试版错误?

As you can see it clearly scrolls on iOS 7 but not on iOS 8. Is there some property that I'm missing here or is it just a beta bug?

推荐答案

虽然我不知道正确的方法,但我无论如何都可以解决这个问题。
如果设置了frame属性(但不是CGRectZero),似乎会滚动视图。
在iOS 8.0.2上工作正常。

Although I dunno the right way, I could solve the issue anyway. Seems like the view scrolls if you set the frame property (but not CGRectZero). It worked fine on 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{};

这篇关于UIAlertController / UIAlertView在iOS 8上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆