2016-04-02 12 views
1

UITableViewを使用してチャットスクリーンを構築しました。私はUITableViewの下にスクロールしたい、画面がいくつかの他のビューコントローラから開いている瞬間。下の機能に簡単なスクロールを使用して、チャットがlong.Isがある場合ジャークを示しています代替ですか?UITableViewの一番下までスクロール

- (void)viewWillAppear:(BOOL)animated { 

    [super viewWillAppear:animated]; 

    dispatch_async(dispatch_get_main_queue(), ^{ 

     NSIndexPath* lastIndexPath = [NSIndexPath indexPathForRow:_messagesArray.count-1 inSection:0]; 
     [_tableView scrollToRowAtIndexPath:lastIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO]; 
    }); 
} 
+0

使用setContentOffset代わりに –

答えて

0

利用UITableViewScrollPositionBottomの代わりUITableViewScrollPositionTop

0
- (void)viewWillAppear:(BOOL)animated { 

    [super viewWillAppear:animated]; 

    dispatch_async(dispatch_get_main_queue(), ^{ 
     CGFloat height = _tableView.contentSize.height - _tableView.bounds.size.height; 
     [_tableView setContentOffset:CGPointMake(0, height) animated:YES]; 
    }); 
} 
0

私はこれは何をしたいと思う:

extension UITableView { 

    func scrollToBottom() { 
     scrollToRow(at: IndexPath(row: numberOfRows(inSection: numberOfSections-1)-1, section: numberOfSections-1), 
        at: .bottom, animated: true) 
    } 
} 
関連する問題