如何在不同变量的alertView中显示多条消息?UIAlertView显示多条消息
回答
构建从多个变量所需的NSString
,如:
NSString *foo;
NSString *bar;
NSString *baz;
// ... set values for foo, bar and baz ...
NSString *myMessage = [NSString stringWithFormat:@"%@ %@ %@", foo, bar, baz];
然后设置你的警报视图使用复合消息myMessage
:
NSString *myTitle = @"xyz";
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: myTitle
message: myMessage
delegate: nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
[alert release];
我想在多行显示标题和值。例如...总时间播放:30,总分:90 ...我现在计算的值只需要显示相应的标题with.You现在的想法? – 2011-04-26 07:13:51
您可以将新行字符('\ n')添加到消息字符串中,以便拥有“多行”:http://en.wikipedia.org/wiki/Newline – 2011-04-26 07:16:02
thanks..it's working..i wish if我可以做一个动态的AlertViewController ...任何想法如何做到这一点? – 2011-04-26 07:29:20
NSString *[email protected]"total time played:30\n";
NSString *[email protected]"total score :90\n";
NSString *[email protected]"19/2/20010 12:00:77\n";
NSString *string=[NSString stringWithFormat:@"%@%@%@",string1,string2,string3];
UIAlertView *progressAlert = [[UIAlertView alloc] initWithTitle:@"Hello" message:string delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
[progressAlert show];
[progressAlert release];
你不妨割肉出局你的问题多一点,但根据我对你的问题的理解,你应该只能使用
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...
UIAlertView构造函数。然后将您的变量连接成一个NSString
对象,并将其作为(NSString*)message
传递给对象。
+ (id)stringWithFormat:(NSString *)format, ...
工厂方法使这个微不足道的。我会推荐reading your options with NSString in the Apple documentation。
NSString *[email protected]"Message 1.";
NSString *str2= @"Message 2.";
NSString *str3 = @"Message 3";
NSString *msg=[NSString stringWithFormat:@"%@\n%@\n%@",str1,str2,str3];
FreeCoinsCustomAlert* alert = [[FreeCoinsCustomAlert alloc] initWithTitle:msg
message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
- 1. UIAlertView消息显示屏
- 2. UIAlertView消息
- 3. 崩溃与多UIAlertView中消息
- 4. UIAlertView“非阻塞”显示消息确实保留了视图?
- 5. 显示文本框条目的消息
- 6. 显示进度条或等待消息
- 7. 仅显示一条C#消息
- 8. 显示消息
- 9. 显示消息
- 10. 显示消息
- 11. UIAlertView以OK显示信息性声明
- 12. JSQMessagesViewController显示每条消息的消息时间
- 13. UIAlertView中切断消息
- 14. UIAlertView不显示
- 15. UIAlertView显示NULL
- 16. 消息队列中的多条消息
- 17. 使用ng-messages为不同表单域显示多条消息
- 18. Android在单个通知中显示多条消息
- 19. PHP MySQL根据多个条件显示消息
- 20. 在VB.NET中完成进度条显示时多次显示消息框
- 21. MFC - 显示消息
- 22. vb消息显示
- 23. angularJS显示消息
- 24. JOptionPane显示消息
- 25. C#消息框连续多次显示
- 26. 为PrimeFaces显示fileupload的多个消息/咆哮消息
- 27. 回声消息但显示消息
- 28. 显示Django消息框架消息
- 29. Django消息框架不显示消息?
- 30. H:消息不显示JSF消息
你是什么意思的多个???请解释你的问题.... – 2011-04-26 07:06:10
你的意思是说多个消息??? – 2011-04-26 07:06:20
喜欢不同的价值和不同的标题。喜欢玩的时间:30;分数:90%。然后显示在不同的行。现在清楚了吗? – 2011-04-26 07:16:33