Skip to content

Instantly share code, notes, and snippets.

View kenshin03's full-sized avatar

Kenny Tang kenshin03

View GitHub Profile
@kenshin03
kenshin03 / gist:5494256
Created May 1, 2013 08:03
ascync loading background image and extracting its background color with LEColorPicker
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if (!self.imageURLString){
self.imageURLString = self.sourceAvartarImageURL;
self.backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
}
UIImage * feedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.imageURLString]]];
dispatch_async(dispatch_get_main_queue(), ^{
self.backgroundImageView.alpha = 0.0f;
@kenshin03
kenshin03 / gist:5494312
Created May 1, 2013 08:25
comments view controller
-(IBAction)commentButtonTapped:(id)sender {
if (self.commentsPostingView.hidden == YES){
if (self.commentsViewController != nil){
self.commentsViewController = nil;
[self.commentsViewController.view removeFromSuperview];
[self.commentsViewController removeFromParentViewController];
}
self.commentsViewController = [[PSHCommentsViewController alloc] init];
@kenshin03
kenshin03 / gist:5494316
Created May 1, 2013 08:26
animating the bouncing "LIKE" image
- (void) likeFeed {
UIImageView * animatedLikeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"coverfeed-like_button"]];
animatedLikeImageView.frame = CGRectMake(80.0f, 210.0f, 160.0f, 160.0f);
animatedLikeImageView.contentMode = UIViewContentModeScaleToFill;
self.animatedLikeImageView = animatedLikeImageView;
self.animatedLikeImageView.hidden = YES;
[self.view addSubview:self.animatedLikeImageView];
double delayInSeconds = .3;
// 1. set up the intial view with the first Feed Item
- (void) initFeedsPageViewController {
...
FeedItem * firstFeedItem = self.feedItemsArray[0];
PSHCoverFeedPageViewController * currentPagePageViewController = [[PSHCoverFeedPageViewController alloc] init];
currentPagePageViewController.feedType = firstFeedItem.type;
currentPagePageViewController.messageLabelString = firstFeedItem.message;
@kenshin03
kenshin03 / gist:5497062
Created May 1, 2013 18:11
output from ACAccountStore accountTypeWithAccountTypeIdentifier:
2013-05-01 10:06:06.036 Home[87441:1c03] granted: 1
2013-05-01 10:06:06.040 Home[87441:1303] accounts: (
"type:com.apple.facebook\nidentifier: F5D9D131-7A36-4FFD-A187-A09B07DDF86F\naccountDescription: Facebook\nusername: [email protected]\nobjectID: x-coredata://92135DD2-592B-4F75-87FF-9965AE7E3B13/Account/p2\nenabledDataclasses: {(\n \"com.apple.Dataclass.Contacts\",\n \"com.apple.Dataclass.Calendars\"\n)}\nenableAndSyncableDataclasses: {(\n)}\nproperties: {\n fullname = \"Kenny Tang\";\n uid = 572733568;\n}\nparentAccount: (null)\nowningBundleID:(null)"
)
@kenshin03
kenshin03 / gist:5551606
Created May 10, 2013 00:23
hide menu buttons
/*
// expanded
self.expandedMenuButtonFrame = CGRectMake(120.0f, 458.0f, 90.0f, 90.0f);
self.expandedMessengerButtonFrame = CGRectMake(10.0f, 429.0f, 72.0f, 110.0f);
self.expandedLauncherButtonFrame = CGRectMake(124.0f, 306.0f, 72.0f, 110.0f);
self.expandedNotificationsButtonFrame = CGRectMake(240.0f, 429.0f, 72.0f, 110.0f);
// collapsed
self.collapsedButtonsFrame = CGRectMake(124.0f, 430.0f, 72.0f, 110.0f);
*/
@kenshin03
kenshin03 / gist:5551611
Created May 10, 2013 00:25
animate menu expand
- (void) animateExpandMenuButtons {
self.launcherButtonView.hidden = NO;
self.notificationsButtonView.hidden = NO;
self.messengerButtonView.hidden = NO;
self.launcherButtonLabel.hidden = NO;
self.notificationsButtonLabel.hidden = NO;
self.messengerButtonLabel.hidden = NO;
[UIView animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
@kenshin03
kenshin03 / gist:5551666
Created May 10, 2013 00:36
PSHMenuGestureRecognizer
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
UIView * menuView = [self.view viewWithTag:kPSHMenuViewControllerMenuButtonViewTag];
if (CGRectContainsPoint(menuView.frame, touchPoint)){
[self setState:UIGestureRecognizerStateBegan];
self.menuViewBeingMoved = menuView;
}else{
@kenshin03
kenshin03 / gist:5551676
Created May 10, 2013 00:38
menuGestureRecognizerAction
- (void) menuGestureRecognizerAction:(PSHMenuGestureRecognizer*)recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan){
// began moving
} else if (recognizer.state == UIGestureRecognizerStateChanged){
CGRect launcherButtonImageViewFrame = [self.view convertRect:self.launcherButtonImageView.frame fromView:self.launcherButtonImageView.superview];
@kenshin03
kenshin03 / gist:5602000
Created May 17, 2013 21:12
Fetch notifications
- (void) fetchNotifications:(FetchNotificationsSuccess)fetchNotificationsSuccess {
InitAccountSuccessBlock successBlock = ^{
NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/notifications"];
SLRequest * request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:url parameters:@{@"include_read":@"true"}];
DDLogVerbose(@"request.URL: %@", request.URL);
request.account = self.facebookAccount;