2009年8月18日 星期二

modify view class for view controller

from view controller's xib,
click on view,
from inspector panel, click information ,
change class to the view class you want

2009年8月13日 星期四

game kit bluetooth connection problem

try
method 1:
turn off wifi

method 2:
restart iphone

2009年8月12日 星期三

trigger iphone vibrate

1. include AudioToolBox.framework

2.
#import
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

2009年8月4日 星期二

get current time

NSCalendar *calendar= [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSCalendarUnit unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |
NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit |
NSSecondCalendarUnit;
NSDate *date = [NSDate date];
NSDateComponents *dateComponents = [calendar components:unitFlags
fromDate:date];
NSInteger year = [dateComponents year];
NSInteger month = [dateComponents month];
NSInteger day = [dateComponents day];
NSInteger hour = [dateComponents hour];
NSInteger minute = [dateComponents minute];

[calendar release];

2009年8月1日 星期六

animation delegate

1. initial
// if want to change something, such as move a UIImageView,
// then pass this UIImageView as context argument
[UIView beginAnimations:@"test" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:
@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];

2. when animation finish, animationDidStop is called

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished
context:(void *)context

NSThread

do sth on main thread , and wait until done

ex:

[self performSelectorOnMainThread:@selector(loadPhoto) withObject:nil waitUntilDone:YES];