2009-10-01 11 views
17

Ich kann das nirgendwo finden. Ich möchte nicht jedes Mal den Debugger benutzen müssen. Wie bekomme ich Drucknachrichten auf dem iPhone?Iphone Popup Warnmeldung

Antwort

41

die NSLog-Funktion:

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

Die Meldungen an das Konsolenprotokoll geschrieben werden. Sie können sie im Simulator ansehen, indem Console.app läuft oder von XCode Debugger/Konsolenansicht (XCode -> Run -> Console)

Schalt Wenn Sie wirklich ein Popup-Alarm (wie die Javascript-Funktion alert()) tun wollen, können Sie dies tun:

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

FYI UIAlertView ist jetzt mit iOS 8. –

+1

Beispiel dafür, wie veraltet ersetzen 'UIAlertView' mit neuen' 'UIAlertController man kann finden Sie hier: http://useyourloaf.com/blog/2014/09/05/uialertcontroller-changes-in-ios-8.html – andi

+0

oder in der offiziellen Dokumentation: https: // Entwickler .apple.com/library/ios/documentation/UIKit/Referenz/UIAlertController_class/index.html #/apple_ref/occ/cl/UIAlertController – andi

1

Suchen Sie mit Google oder dem Xcode Documentation Viewer nach UIAlertView.

3
UIAlertView* alert; 
alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"Much more info" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
[alert show]; 
[alert release]; 
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]; 

Beispielbilder:

enter image description here

+0

funktioniert wie ein Charme. GEWECKT! :) –

+0

Danke Tony Gil –