2009-10-01 13 views

Odpowiedz

41

Użyj funkcji NSLog:

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

Komunikaty sposób zapisany w dzienniku konsoli. Można zobaczyć je w symulatorze uruchamiając Console.app lub przełączając XCode do debugera/widoku konsoli (XCode -> Run -> Console)

Jeśli naprawdę chcesz zrobić alert popup (jak javascript alert() funkcji) można zrobić:

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 jest teraz przestarzała z iOS 8. –

+1

przykład jak zastąpić 'UIAlertView' z nowym' 'można UIAlertController tutaj: http://useyourloaf.com/blog/2014/09/05/uialertcontroller-changes-in-ios-8.html – andi

+0

lub w oficjalnej dokumentacji: https: // programista .apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/index.html # // apple_ref/occ/cl/UIAlertController – andi

1

Poszukaj UIAlertView za pomocą Google lub Xcode Documentation Viewer.

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

Przykładowe zdjęcia:

enter image description here

+0

działa jak czar. UPVOTED! :) –

+0

Dzięki Tony Gil –

Powiązane problemy