2011年9月29日 星期四

NSTimer change repeat time


step1 
static NSTimer *timer;
step2
[timer invalidate];
step3
timer = [NSTimer scheduledTimerWithTimeInterval:newtime 
                                              target:self 
                                            selector:@selector(myMethod:)
                                            userInfo:nil 
                                             repeats:YES];

2011年9月26日 星期一

Converting a CGPoint to NSValue


+ (NSValue *)valueWithCGPoint:(CGPoint)point
See iPhone doc

Creating a left-arrow button (like UINavigationBar's “back” style) on a UIToolbar


// create button
UIButton* backButton = [UIButton buttonWithType:101]; // left-pointing shape!
[backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
[backButton setTitle:@"Back" forState:UIControlStateNormal];
// create button item -- possible because UIButton subclasses UIView!
UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
// add to toolbar, or to a navbar (you should only have one of these!)
[toolbar setItems:[NSArray arrayWithObject:backItem]];
navItem.leftBarButtonItem = backItem;