Ios UIAlertController是否支持具有滚动功能的大量文本?

Ios UIAlertController是否支持具有滚动功能的大量文本?,ios,iphone,swift,ios8,Ios,Iphone,Swift,Ios8,UIAlertController显示小字符串。当字符串的大小变大时。然后,此警报中的某些文本丢失。是否有任何滚动功能可用于滚动到剩余文本 var alert = UIAlertController(title: "title here", message: "about 30 line text here", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "OK",

UIAlertController显示小字符串。当字符串的大小变大时。然后,此警报中的某些文本丢失。是否有任何滚动功能可用于滚动到剩余文本

var alert = UIAlertController(title: "title here", message: "about 30 line text here", preferredStyle: UIAlertControllerStyle.Alert)
    alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
    self.presentViewController(alert, animated: true, completion: nil)

如何发出提示,显示大于30行的文本。我使用swift。

它在目标C中对我很有效:

 NSString* messageString = @"Enter your Long text here";

 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];
对于Swift,您可以使用以下代码:

let alertController = UIAlertController(title: "Your Title", message: "Your Text", preferredStyle: .Alert)

let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in
    println(action)
}
alertController.addAction(cancelAction)

let destroyAction = UIAlertAction(title: "Destroy", style: .Destructive) { (action) in
    println(action)
}
alertController.addAction(destroyAction)

self.presentViewController(alertController, animated: true) {
 // ...
}

它在操场上不费吹灰之力就能工作:

import UIKit
import PlaygroundSupport

PlaygroundPage.current.needsIndefiniteExecution = true
let window = UIWindow()
let viewController = UIViewController()
window.rootViewController = viewController
window.makeKeyAndVisible()

let message = (1...1000).reduce("") { $0 + "\($1)\n" }

let alert = UIAlertController(title: "title here", message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "action here", style: .default, handler: nil))
viewController.present(alert, animated: true, completion: nil)
PlaygroundPage.current.liveView = window
我有1000条可滚动的线:


不要这样做。警报是传达大量信息的不适当方式。在其他情况下可以使用什么@马特托德。我想我记得几个月前,它通过垂直滑动来处理长文本。但是现在我发现它在我的Objective-C代码中也不起作用。我最初的怀疑是,我的一些与我自己的滚动控件相关的底层设置会产生干扰。但是,我还没有检查出来。这是Objective-c,而且它不能处理长文本。当文本大于屏幕大小时,不会显示滚动效果。此答案中给出的swift版本与问题1相同。不适用于大文本。如何导入PlaygroundSupport。我没有那个模块?Thanks@RJB如果你在一个iOS项目中,那么你就不需要相对于游戏场的代码行。游乐场项目只是让你不用创建应用程序就可以进行测试。至少在Xcode 8、9和10上可用。