2016-04-02 15 views
1

UITableView kullanarak yerleşik bir sohbet ekranım var. Ekranın diğer görüntü denetleyicilerinden açıldığı an UITableView'un altına kaydırmak istiyorum.Ancak işlevler için önemsiz kaydırma kullanıldığında, sohbet uzunsa bir pislik gösterir. Bir alternatif var mı?UITableView'da aşağıya kaydır

- (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

kullanım setContentOffset yerine –

cevap

0

Kullanım UITableViewScrollPositionBottom yerine 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

Bunun istediğini düşünüyorum:

extension UITableView { 

    func scrollToBottom() { 
     scrollToRow(at: IndexPath(row: numberOfRows(inSection: numberOfSections-1)-1, section: numberOfSections-1), 
        at: .bottom, animated: true) 
    } 
} 
İlgili konular