objective-c Iphone 弹出提示信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1501589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 22:17:20  来源:igfitidea点击:

Iphone popup alert message

iphoneobjective-c

提问by DevDevDev

I can't find this anywhere. I don't want to have to use the debugger everytime. How do I get print messages on the iphone.

我在任何地方都找不到这个。我不想每次都使用调试器。如何在 iphone 上获取打印消息。

回答by Jason Jenkins

Use the NSLog function:

使用 NSLog 函数:

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

The messages get written to the console log. You can view them in the simulator by running Console.app or by switching XCode to the Debugger/Console view (XCode -> Run -> Console)

消息被写入控制台日志。您可以通过运行 Console.app 或将 XCode 切换到 Debugger/Console 视图来在模拟器中查看它们(XCode -> Run -> Console)

If you really want to do a popup alert (like the javascript alert()function) you can do :

如果你真的想做一个弹出式警报(比如 javascriptalert()函数),你可以这样做:

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

回答by Adrian Pirvulescu

// 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];
// 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];

Sample images:

示例图像:

enter image description here

在此处输入图片说明

回答by Rob

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

回答by jbrennan

Look for UIAlertViewwith either Google or the Xcode Documentation Viewer.

UIAlertView使用 Google 或 Xcode 文档查看器查找。