Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何显示来自阵列的所有消息的警报_Ios_Ipad - Fatal编程技术网

Ios 如何显示来自阵列的所有消息的警报

Ios 如何显示来自阵列的所有消息的警报,ios,ipad,Ios,Ipad,我正在从保存在NSMutableArray中的web服务接收消息 如果阵列中有5条消息,我需要在单个警报视图中显示所有消息 NSString *temp; // Here there is only one message, i want to read all message from Array and feed to alert view. UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Info"

我正在从保存在NSMutableArray中的web服务接收消息

如果阵列中有5条消息,我需要在单个警报视图中显示所有消息

NSString *temp; // Here there is only one message, i want to read all message from Array and feed to alert view.

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Info"
                            message: temp
                            delegate:nil
                            cancelButtonTitle:@"OK"
                            otherButtonTitles:nil];
[alertView show];
你可以用这个

NSString * temp = [yourArray componentsJoinedByString:@" "];
注意:如果您需要任何连接的组件,如
等,您可以相应地进行修改。如果要将空间作为连接的组件,请使用此
@”“(单个空间),@“\n”(多行)

您可以使用此

NSString * temp = [yourArray componentsJoinedByString:@" "];
注意:如果您需要任何连接的组件,如
等,您可以相应地进行修改。如果要将空间作为连接的组件,请使用此
@”“(单个空间),@“\n”(多行)

这是您的代码

NSArray *alertArr = @[@"alert1", @"alert2", @"alert3", @"alert4", @"alert5"];
NSString *temp;
temp = [alertArr componentsJoinedByString:@"\n"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Info"
                                                    message: temp
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
[alertView show];
这是你的密码

NSArray *alertArr = @[@"alert1", @"alert2", @"alert3", @"alert4", @"alert5"];
NSString *temp;
temp = [alertArr componentsJoinedByString:@"\n"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Info"
                                                    message: temp
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
[alertView show];

为什么不干脆
temp=[alertArr组件通过字符串连接:@“\n”]?感谢您的代码deanWombourneWhy,不仅仅是
temp=[alertArr componentsJoinedByString:@“\n”]?感谢您的代码deanWombournethank非常感谢,这显示了所有消息,是否有任何方法可以区分所有消息。它像第1234段那样展示了一些需要区分的东西。@user2813740我认为,这是展示(1234)的最好方式。若你们指定了格式,我会告诉你们哪一个是可能的,哪一个是不可能的?我的意思是它看起来就像一段。。我想知道我是否可以在按摩前做一些类似>或*的事情,或者给颜色另一种方式…。使它们更具可读性。。基本上,这些都是给用户的通知消息…你明白我的意思了。。我知道我必须去定制可能是…但如果你有任何想法或任何样本代码…@user2813740我不明白你的段落风格。只需显示示例文本(段落样式)。看到这篇文章给字符串着色。试试NSAttributedString,它可能不起作用,我没有试过这个。因为
initWithTitle:..
的类型随
NSAttributedString
的不同而不同。非常感谢,这显示了所有消息,有没有办法区分所有消息。它像第1234段那样展示了一些需要区分的东西。@user2813740我认为,这是展示(1234)的最好方式。若你们指定了格式,我会告诉你们哪一个是可能的,哪一个是不可能的?我的意思是它看起来就像一段。。我想知道我是否可以在按摩前做一些类似>或*的事情,或者给颜色另一种方式…。使它们更具可读性。。基本上,这些都是给用户的通知消息…你明白我的意思了。。我知道我必须去定制可能是…但如果你有任何想法或任何样本代码…@user2813740我不明白你的段落风格。只需显示示例文本(段落样式)。看到这篇文章给字符串着色。试试NSAttributedString,它可能不起作用,我没有试过这个。因为
initWithTitle:..
的类型随
NSAttributedString
的变化而变化。