find . -type d -name .svn -depth -exec rm -rf {} \;
read more"Add toolbar to the bottom"
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
[super loadView];
UIToolbar *toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleBlackTranslucent;
// create a bordered style button with custom title
UIBarButtonItem *playItem = [[[UIBarButtonItem alloc] initWithTitle:@"Play"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(playAction:)] autorelease];
UIBarButtonItem *emailItem = [[[UIBarButtonItem alloc ...
read more"Clear UIView during drawing"
//Please note. To make view transparent you need to add:
//self.backgroundColor = [UIColor clearColor];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, self.bounds);
read more"How to change style and color of the navigation bar"
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
self.navigationController.navigationBar.tintColor = [UIColor redColor];
read more"Get path for file included into project"
NSString *moviePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"filename.file"];
read more"Play Sound Effect"
#import "SoundEffect.h"
// init sound
NSBundle *mainBundle = [NSBundle mainBundle];
SoundEffect *tapSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"tap_snd" ofType:@"caf"]];
// play sound
[tapSound play];
"Create UILabel in runtime"
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 70)];
label.numberOfLines = 2;
label.text = @"text";
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];
label.highlightedTextColor = [UIColor blackColor];
label.textAlignment = UITextAlignmentLeft;
label.font = [UIFont systemFontOfSize:12];
[self.view addSubview:label];
[label release];
read more"Hide navigation bar for navigation controller"
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self navigationController].navigationBarHidden = YES;
}
- (void)viewDidDisappear:(BOOL)animated {
[self navigationController].navigationBarHidden = NO;
}
read more"Run method in background"
[NSThread detachNewThreadSelector:@selector(doSomethingInBack:) toTarget:self withObject:nil];
read more-(void) doSomethingInBack:(id)anObject {
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
//place code you want to run in different thread HERE
[NSThread exit];
//we need to do this to prevent memory leaks
[autoreleasepool release];
}
"Send email with attachments on iPhone"
//Additionals acctions to do:
// - add source code from attached ZIP;
// - add CFNetwork.framework to project;
// - your class should implement <SKPSMTPMessageDelegate> protocol.
#import "SKPSMTPMessage.h"
#import "NSData+Base64Additions.h"
#import <SystemConfiguration/SCNetworkReachability.h>
#include <netinet/in.h>
- (void)sendMessageInBack:(id)anObject{
NSLog(@"Start Sending");
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString ...
read more