Iphone弹出警报消息

时间:2009-10-01 02:21:01

标签: iphone objective-c

我无处可寻。我不想每次都使用调试器。如何在iphone上获取打印消息。

4 个答案:

答案 0 :(得分:42)

使用NSLog功能:

NSLog(@"Your message here.");
// with parameters:
NSString * myParam = @"Some value";
NSLog(@"myParam:%@", myParam);

消息将写入控制台日志。您可以通过运行Console.app或将XCode切换到调试器/控制台视图(XCode -> Run -> Console)

在模拟器中查看它们

如果您真的想要执行弹出式提醒(例如javascript alert()功能),您可以这样做:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test Message" 
                                                  message:@"This is a sample"
                                                 delegate:nil
                                        cancelButtonTitle:@"OK" 
                                        otherButtonTitles:nil];
[alert show];
[alert release];

答案 1 :(得分:4)

// open a alert with an OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView"
        message:@"My message" delegate:self cancelButtonTitle:@"Cancel"
        otherButtonTitles:@"OK", nil];
[alert show];
[alert release];

示例图片:

enter image description here

答案 2 :(得分:3)

UIAlertView* alert;
alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"Much more info" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];

答案 3 :(得分:1)

使用Google或Xcode文档查看器查找{​​{1}}。

相关问题