Created
September 24, 2010 11:40
-
-
Save alexrepty/595226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { | |
UIImageView *thumbImageView = (UIImageView *)context; | |
if ([keyPath isEqualToString:kARPageScrubberViewKeypathFrame]) { | |
self.bubbleView.pageNumber = self.pageIndex + 1; | |
CGRect bubbleViewFrame = self.bubbleView.frame; | |
bubbleViewFrame.origin.x = thumbImageView.frame.origin.x - round(bubbleViewFrame.size.width / 2) + _slider.frame.origin.x + round(thumbImageView.frame.size.width / 2); | |
bubbleViewFrame.origin.y = thumbImageView.frame.origin.y - bubbleViewFrame.size.height; | |
self.bubbleView.frame = bubbleViewFrame; | |
if (self.bubbleView.hidden && _slider.tracking) { | |
[self.bubbleView show:YES]; | |
} | |
} else if ([keyPath isEqualToString:kARPageScrubberViewKeypathTracking]) { | |
if (_slider.tracking) { | |
if (self.bubbleView.hidden) { | |
[self.bubbleView show:YES]; | |
} | |
return; | |
} else { | |
[_slider setValue:self.pageIndex animated:YES]; | |
} | |
if (nil != _bubbleTimer) { | |
[_bubbleTimer invalidate]; | |
[_bubbleTimer release]; _bubbleTimer = nil; | |
} | |
_bubbleTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:0.25f] interval:0.0f target:self.bubbleView selector:@selector(hide) userInfo:nil repeats:NO]; | |
[[NSRunLoop currentRunLoop] addTimer:_bubbleTimer forMode:NSDefaultRunLoopMode]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment