Translate

2013年7月11日 星期四

讓UIView或UIScrollView的動畫暫停跟繼續動畫

-(void)pauseLayer:(CALayer*)layer { CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; layer.speed = 0.0; layer.timeOffset = pausedTime; } -(void)resumeLayer:(CALayer*)layer{ CFTimeInterval pausedTime = [layer timeOffset]; layer.speed = 1.0; layer.timeOffset = 0.0; layer.beginTime = 0.0; CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime; layer.beginTime = timeSincePause; }

2013年7月8日 星期一

iOS6 UUID

最近剛好碰到推播註冊
卻讓我自己混入了一團迷思裡面
因為我一直把推播註冊的token跟UUID搞混了
真是個笨蛋ㄚ

參考link

[UIDevice currentDevice].identifierForVendor.UUIDString;
or
NSString *uuid_str = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; uuid_str = [uuid_str stringByReplacingOccurrencesOfString:@"-" withString:@""];

2013年7月1日 星期一

iPad willAnimateRotationToInterfaceOrientation

這幾天再寫個ipad專案
發現有時候willAnimateRotationToInterfaceOrientation沒有被呼叫到
所以上網查了一下資料
參考link
This is expected behavior as I see it. If the UIVC is not on the top of the stack, then willAnimateRotationToInterfaceOrientation shouldn't be called as no rotation is being animated at that time. The way I've been handling this in the app I am working on now is similar to the above poster. Any UIVC that supports all orientations gets a new method

- (void) updateLayoutForNewOrientation: (UIInterfaceOrientation) orientation;

This method is called from two places:

-(void) viewWillAppear: (BOOL) animated { [super viewWillAppear: animated]; [self updateLayoutForNewOrientation: self.interfaceOrientation]; }
-(void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation duration: (NSTimeInterval) duration { [self updateLayoutForNewOrientation: interfaceOrientation]; }
The new method is simple:

- (void) updateLayoutForNewOrientation: (UIInterfaceOrientation) orientation { if (UIInterfaceOrientationIsLandscape(orientation)) { // Do some stuff } else { // Do some other stuff } }