Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. - (void)updateTableContentInset {
  2. NSInteger numRows = [self tableView:self.tableView numberOfRowsInSection:0];
  3. CGFloat contentInsetTop = self.tableView.bounds.size.height;
  4. for (NSInteger i = 0; i < numRows; i++) {
  5. contentInsetTop -= [self tableView:self.tableView heightForRowAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
  6. if (contentInsetTop <= 0) {
  7. contentInsetTop = 0;
  8. break;
  9. }
  10. }
  11. self.tableView.contentInset = UIEdgeInsetsMake(contentInsetTop, 0, 0, 0);
  12. }
  13.  
  14. dataSourceArray = dataSourceArray.reverseObjectEnumerator.allObjects;
  15.  
  16. func updateTableContentInset() {
  17. let numRows = tableView(tableView, numberOfRowsInSection: 0)
  18. var contentInsetTop = tableView.bounds.size.height
  19. for i in 0..<numRows {
  20. contentInsetTop -= tableView(tableView, heightForRowAtIndexPath: NSIndexPath(forItem: i, inSection: 0))
  21. if contentInsetTop <= 0 {
  22. contentInsetTop = 0
  23. }
  24. }
  25. tableView.contentInset = UIEdgeInsetsMake(contentInsetTop, 0, 0, 0)
  26. }
  27.  
  28. func updateTableContentInset() {
  29. let numRows = tableView(tableView, numberOfRowsInSection: 0)
  30. var contentInsetTop = self.tableView.bounds.size.height
  31. for i in 0..<numRows {
  32. contentInsetTop -= tableView(tableView, heightForRowAt: IndexPath(item: i, section: 0))
  33. if contentInsetTop <= 0 {
  34. contentInsetTop = 0
  35. }
  36. }
  37. tableView.contentInset = UIEdgeInsetsMake(contentInsetTop, 0, 0, 0)
  38. }
  39.  
  40. NSString *yourObject = dataArray[[dataArray count] - 1 - indexPath.row];
  41. cell.textLabel.text = yourObject
  42.  
  43. -(void)startObservingContentSizeChanges
  44. {
  45. [self.tableView addObserver:self forKeyPath:kKeyPathContentSize options:0 context:nil];
  46. }
  47.  
  48. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
  49. {
  50. if([keyPath isEqualToString:kKeyPathContentSize] && object == self.tableView)
  51. {
  52. // difference between content and table heights. +1 accounts for last row separator
  53. CGFloat height = MAX(self.tableView.frame.size.height - self.tableView.contentSize.height, 0) + 1;
  54.  
  55. self.tableView.contentInset = UIEdgeInsetsMake(height, 0, 0, 0);
  56.  
  57. // "scroll" to top taking inset into account
  58. [self.tableView setContentOffset:CGPointMake(0, -height) animated:NO];
  59.  
  60. }
  61. }
  62.  
  63. let reverseIndex = myArray.count-indexPath.row-1
  64.  
  65. let currCellData = myArray.object(at: reverseIndex)
  66.  
  67. self.tableView.transform = CGAffineTransform.init(rotationAngle: (-(CGFloat)(M_PI)))
  68. self.tableView.transform = CGAffineTransform.init(translationX: -view.frame.width, y: view.frame.height)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement