 |
 |
|
| |
 |
|
|
|
|
Create a Simple iOS On-Screen Logging Console
Tuesday, March 13, 2012, by Sebastian Dwornik
Sometimes it can be useful to have a simple text console on-screen within your iOS app to output status info and other messages that can help analyze a running app.
Hence the creation of textViewLog:() function.
Simply add the following UItextView control setup.
@property (nonatomic, strong) IBOutlet UITextView *textConsole; @synthesize textConsole;
Insert a UItextView control within your View and connect its outlet to our property.

Finally drop in the code below.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // It's almost like NSLog, but directed to a UITextView control. // // usage example: [self textViewLog:@"%@", myVar]; // - (void)textViewLog:(NSString *)firstArg, ... { va_list args;
va_start(args, firstArg);
NSString *log_msg = [[NSString alloc] initWithFormat:firstArg arguments:args];
self.textConsole.text = [NSString stringWithFormat:@"%@%@\n", self.textConsole.text, log_msg];
// Support auto-scroll. NSRange range = NSMakeRange(self.textConsole.text.length - 1, 1); [self.textConsole scrollRangeToVisible:range];
}
And voila! You have yourself a quick and simple on-screen logging console.

You can download the above sample project too.
|
|
 |
Welcome to my App World
My name is Sebastian Dwornik and I am an entrepreneur located near Toronto, Canada.
Here you will find my thoughts on all matters regarding software, design, business, and sometimes life in general.
Have feedback? Don’t be shy and post your comments within the forum.
CONNECT WITH US
Categories
Archives
March
(1)
February
(1)
January
(2)
Past archives (2012)
Past archives (2011)
Past archives (2010)
Past archives (2009)
Past archives (2008)
|
 |
|
|
 |
 |
|
 |
| |
|
Copyright © 2007 - 2013 Applied PDA Software, Inc.
|
|
|
All products mentioned on this web site are owned and copyrighted by their respective companies.
|
|
|