2017-10-18 15 views
1

나는 채팅 응용 프로그램을 작성 중입니다. 내 응용 프로그램에서 부드럽고 정확하지 않은 구현 된 이전 메시지 기능을 whatsapp처럼로드하십시오.더 빨리로드 부드럽게 스크롤

나는 whatspp 응용 프로그램 등 같은 부드러움으로 이전 부하를 달성하기 위해 더 나은 방법 인, 그래서

func scrollViewDidScroll(_ scrollView: UIScrollView) { 

    if scrollView.contentOffset.y >= 0 && scrollView.contentOffset.y <= 50{ 
     print(" scrollViewDidScroll Load Earlier start- \(Utils.stringFromNSDate(Date(), inMillisec: true, useUTC: true)!)") 
     if !self.messageFetcher.isHideLoadMoreDisplay{ 
      if self.messageFetcher.arrayOfallChatMessagesData.count > 0 && !isCheckLoading{ 
       self.isCheckLoading = true 
       let message = self.messageFetcher.arrayOfallChatMessagesData[0] 
       self.messageIdForMessageDisplay = (message.chatMessageId) 
       self.loadMoreDataLoad(threadId: self.messageFetcher.chatThreadId, isloadFromServer: false) 
      } 
     } 
     print(" scrollViewDidScroll Load Earlier end- \(Utils.stringFromNSDate(Date(), inMillisec: true, useUTC: true)!)") 
    } 
} 

를 사용하여 더 많은 데이터를 나열하고 가져 오는 채팅 UITableview을 사용하고 있습니다.

+0

loadMoreDataLoad가 Webservice를 호출합니다 보일 때

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { // load dats here return cell } 

데이터를 새로 고침 원활이되도록 이미지를로드 SDWebimage를 사용할 수 있습니까? 데이터 가져 오기 –

+0

양식 로컬 데이터베이스 가져 오는 중 .. –

+0

페이징의 경우 'cellForRow'에 데이터를로드해야합니다.'loadMoreDataLoad' 메소드를 표시하십시오. –

답변

0

항상 데이터를 CellForWowatIndexpath 메서드로로드하고 마지막 셀이 표시 될 때 페이지 매김을 사용하고 더 많은 데이터를로드해야합니다. cellWillDisplay 메소드에서 더 많은 메소드로드를 호출 할 수 있습니다. 그리고 마지막으로 당신은로드하지 적어도 경우 이미지가 스크롤 마지막 셀이

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 
    let lastItem = self.YourArray.count - 1 

     if indexPath.row == lastItem 
     { 
      //call load more data method 
     } 

    else{ 
     return 
    } 
} 
+0

고사 공유하고 싶습니다.하지만 Whatsapp App과 같이 맨 위에서 구현하고 싶습니다. –