0

我只想在上面显示一些文本,但如果文本长度大于允许的大小UIAlertView,它会显示字符串。"Null"

我很确定文本不会比屏幕大(大约一半多一点),所以我不想让实现 a 变得复杂ScrollView

在更改 uialertview的大小以更改 uialertview 的大小时遇到​​问题AlertView,但它不起作用,另外会产生一些奇怪的视觉效果。

我尝试了这个第三部分组件https://github.com/inamiy/YIPopupTextView,我什至无法通过编译。(已经将这 4 个文件导入到项目中。)我不知道为什么。

所以,实际上我只是想增加允许在AlertView. 任何的想法?

4

2 回答 2

3

我写了一个小测试程序。这是我添加到单一视图应用程序模板的唯一内容:

- (void)viewDidAppear:(BOOL)animated {
    NSMutableString *message = [[NSMutableString alloc] init];
    while (message.length < 100000) {
        [message appendString:@"Hello, world!  "];
    }
    [message appendString:@"This is the end."];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test" message:message delegate:nil cancelButtonTitle:@"Done" otherButtonTitles:nil];
    [alert show];
}

这在运行 iOS 5.0 的 iPhone 模拟器和运行 iOS 6.0.2 的 iPhone 5 上运行良好。显示所有文本(在可滚动的文本视图中)。

您的问题可能不在于文本的大小。

于 2013-01-24T09:15:55.853 回答
0

当我显示在字典中解析的 JSON 对象的结果然后打印在 alertView 上(在 Xcode 5.1.1 上,在 iphone 64 位模拟器上为 iOS 7.1 编译)时,我发现了一个奇怪的行为。对于相同的输入数据:

[[UIAlertView alloc]initWithTitle:@"something" message:[[[NSString stringWithFormat:@"json:%@",[inputData dictionaryRepresentation]] stringByReplacingOccurrencesOfString:@" "withString:@""]substringToIndex:7035] delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];

正确打印,但如果我说“substringToIndex:7036”它只显示空格......没有“stringByReplacingOccurrencesOfString:”方法,限制远远超出:

[[UIAlertView alloc]initWithTitle:@"something" message:[[NSString stringWithFormat:@"json:%@",[inputData dictionaryRepresentation]] substringToIndex:13768] delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];

正确打印,而不是“substringToIndex:13769”不打印......我意识到这不是最大长度的问题,而是JSON对象内的特殊字符

于 2014-11-06T14:36:17.043 回答