Skip to content

Instantly share code, notes, and snippets.

@keicoder
Created February 13, 2014 06:05
Show Gist options
  • Select an option

  • Save keicoder/8970574 to your computer and use it in GitHub Desktop.

Select an option

Save keicoder/8970574 to your computer and use it in GitHub Desktop.
objective-c : make basic table view with custom background and jason data v.6
//make basic table view with custom background and jason data v.6
//following Collision Behavior 델리게이트 -> 상단 바운더리를 두어 스냅 시 상단에 뷰가 snap되도록 코딩
//DynamicSandwichViewController.m
@interface DynamicSandwichViewController () <UICollisionBehaviorDelegate> //Collision Behavior 델리게이트
- (UIView*)addRecipeAtOffset:(CGFloat)offset forSandwich:(NSDictionary*)sandwich {
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));}
...
// 4. Upper boundary
boundaryStart = CGPointMake(0.0, 0.0);
boundaryEnd = CGPointMake(self.view.bounds.size.width, 0.0);
[collision addBoundaryWithIdentifier:@2 fromPoint:boundaryStart toPoint:boundaryEnd];
collision.collisionDelegate = self;
...
return view;
}
#pragma mark - Collision Behavior 델리게이트
- (void)collisionBehavior:(UICollisionBehavior *)behavior beganContactForItem:(id<UIDynamicItem>)item
withBoundaryIdentifier:(id<NSCopying>)identifier atPoint:(CGPoint)p {
if ([@2 isEqual:identifier]) {
UIView* view = (UIView*) item;
[self tryDockView:view]; //뷰를 창 상단에 docking 시킬지 여부 결정
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment