如何在不同变量的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. Android Studio AlertDialog - 显示多条消息
- 3. 在PHP中显示多条catch消息
- 4. ngMessage不显示多条消息
- 5. UIAlertView显示多次
- 6. 显示一条消息
- 7. UIAlertView消息
- 8. UIAlertView消息太长
- 9. 消息框多次显示
- 10. 崩溃与多UIAlertView中消息
- 11. 当我显示UIAlertView时可以收到消息吗
- 12. 在uialertview中显示nserror消息后,崩溃parseErrorOccurred
- 13. UIAlerView + AFNetworking在UIAlertView中显示错误消息
- 14. “[UIAlertView show]”立即返回,不显示消息弹出框
- 15. UIAlertView中在横向模式下不显示消息
- 16. UIAlertView“非阻塞”显示消息确实保留了视图?
- 17. 有没有办法从模态UIPopover显示消息(如UIAlertView)?
- 18. 显示一条Ajax成功消息
- 19. WooCommerce:向用户显示一条消息
- 20. 显示进度条或等待消息
- 21. 在Android上显示一条消息
- 22. 显示文本框条目的消息
- 23. 进度条显示“回声OFF”消息
- 24. jQuery验证 - 只显示一条消息
- 25. 仅显示一条C#消息
- 26. 显示消息
- 27. 显示消息
- 28. 显示消息
- 29. 显示消息
- 30. 显示消息
你是什么意思的多个???请解释你的问题.... – 2011-04-26 07:06:10
你的意思是说多个消息??? – 2011-04-26 07:06:20
喜欢不同的价值和不同的标题。喜欢玩的时间:30;分数:90%。然后显示在不同的行。现在清楚了吗? – 2011-04-26 07:16:33