Last active
December 19, 2015 07:09
-
-
Save xandrucea/5916470 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
delete separators after last row | |
-------------------------------- | |
self.tableView.tableFooterView = [[UIView alloc] init]; | |
delete last separator line of tableview | |
--------------------------------------- | |
if( indexPath.row == _arrayMenu.count - 1 ){ | |
UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.size.height-1, 320, 2)]; | |
separatorLineView.backgroundColor = [UIColor colorFromHexString:@"#cccccc"]; | |
[cell.contentView addSubview:separatorLineView]; | |
} | |
Scroll to specific cell | |
----------------------- | |
[_tableView reloadData]; | |
for (int i = 0; i < users.count; i++) { | |
Object *user = arry[i]; | |
if ([user.userId isEqualToString:userId]) { | |
int cellPosition = [user.globalRank intValue]; | |
if (cellPosition > 110) { | |
cellPosition = 110; | |
} | |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:cellPosition inSection:0]; | |
[_tableView scrollToRowAtIndexPath:indexPath | |
atScrollPosition:UITableViewScrollPositionMiddle | |
animated:YES]; | |
} | |
} | |
stop highlighting of cell | |
--------------------------- | |
[self.tableView deselectRowAtIndexPath:indexPath animated:YES]; | |
Adding LongPressGesture to TableViewCells | |
init "initLongGestureRecognizer" when VC of tableview will be initialized | |
------------------------------------------------------------------------- | |
- (void)initLongGestureRecognizer{ | |
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] | |
initWithTarget:self | |
action:@selector(handleLongPress:)]; | |
longPress.minimumPressDuration = 1.0f; | |
longPress.delegate = (id)self; | |
[self.tableViewLastGames addGestureRecognizer:longPress]; | |
} | |
- (void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer{ | |
CGPoint p = [gestureRecognizer locationInView:self.tableViewLastGames]; | |
NSIndexPath *indexPath = [self.tableViewLastGames indexPathForRowAtPoint:p]; | |
if(indexPath == nil){ | |
NSLog(@"long press on table view but not on a row"); | |
} else { | |
NSLog(@"long press on table view at row %d", indexPath.row); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment