瀏覽代碼

iOS 7 phone library: let the user expand the collapsed media items with a long touch

Felix Paul Kühne 11 年之前
父節點
當前提交
d8c4cbdd89
共有 1 個文件被更改,包括 29 次插入0 次删除
  1. 29 0
      AspenProject/VLCPlaylistViewController.m

+ 29 - 0
AspenProject/VLCPlaylistViewController.m

@@ -48,6 +48,11 @@
         _tableView.delegate = self;
         _tableView.dataSource = self;
         self.view = _tableView;
+
+        if (SYSTEM_RUNS_IN_THE_FUTURE) {
+            UILongPressGestureRecognizer *gestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(tableViewLongTouchGestureAction:)];
+            [self.view addGestureRecognizer:gestureRecognizer];
+        }
     } else {
         UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
 
@@ -333,6 +338,30 @@
     [self openMediaObject:selectedObject];
 }
 
+#pragma mark - table view gestures
+- (void)tableViewLongTouchGestureAction:(UIGestureRecognizer *)recognizer
+{
+    NSIndexPath *path = [(UITableView *)self.view indexPathForRowAtPoint:[recognizer locationInView:self.view]];
+    UITableViewCell *cell = [(UITableView *)self.view cellForRowAtIndexPath:path];
+
+    CGRect frame = cell.frame;
+    if (frame.size.height > 90.)
+        frame.size.height = 90.;
+    else
+        frame.size.height = 180;
+
+    void (^animationBlock)() = ^() {
+        cell.frame = frame;
+    };
+
+    void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
+        cell.frame = frame;
+    };
+
+    NSTimeInterval animationDuration = .2;
+    [UIView animateWithDuration:animationDuration animations:animationBlock completion:completionBlock];
+ }
+
 #pragma mark - Collection View
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
 {