iPhone SDK Tips & Tricks
[myButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
iPhone SDK Tips & Tricks
[myButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
iPhone SDK Tips & Tricks
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-877-829-7902"]];
iPhone SDK Tips & Tricks
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
myButton.frame = CGRectMake(200, 30, 100, 90); // size and position of button
[myButton setBackgroundImage:[UIImage imageNamed:@"blue_bars.png"] forState:UIControlStateNormal];
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setTitle:@"Call Us\nNow" forState:UIControlStateNormal];
myButton.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
myButton.titleLabel.textAlignment = UITextAlignmentCenter;
myButton.titleLabel.font = [UIFont boldSystemFontOfSize:22];
myButton.backgroundColor = [UIColor clearColor];
iPhone SDK Tips & Tricks
iPhone SDK Tips & Tricks
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
[dateFormat setDateFormat:@"dd-MMM-yyyy"];
NSString *myString = [dateFormat stringFromDate:[NSDate date]];
iPhone SDK Tips & Tricks
#if !(TARGET_IPHONE_SIMULATOR)
NSLog(@"iphone");
#else
NSLog(@"simulator");
#endif
iPhone SDK Tips & Tricks
- (void)buttonClick:(id )sender{
NSLog(@"tag: %d", [sender tag]);
NSLog(@"title: %@", [sender currentTitle]);
}
iPhone SDK Tips & Tricks
NSDateComponents *compsDisplay = [[NSDateComponents alloc] init];
[compsDisplay setDay:25];
[compsDisplay setMonth:12];
[compsDisplay setYear:2012];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *expDate = [gregorian dateFromComponents:compsDisplay];
[compsDisplay release];
int daysRemaining = [expDate timeIntervalSinceNow]/86400;
//minutes - divide by 60
//hours - divide by 3600
NSString *msg = [NSString stringWithFormat:@"%d days remaining.", dayRemaining];