私はチャットアプリケーションを開発中です。私は、テーブルビューでメッセージを表示するView Controllerを持っています。特定のチャットを選択すると、最新のメッセージ12を取得します。&テーブルをリロードし、下にスクロールすると、ユーザーは最近のメッセージ(インデックス11)を見ることができます。 ユーザーはスクロールアップを開始すると(0番目のインデックスに達すると)、Webサービスを介して履歴をフェッチし、同じ順序でスムーズにUIに表示する必要があります。チャット履歴を表示するには、UITableviewのスムーズスクロール
func scrollViewWillBeginDragging(scrollView: UIScrollView) {
pointNow = scrollView.contentOffset
}
func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if (scrollView.contentOffset.y < pointNow.y)
{
self.fetchChatHistory()
}
}
self.fetchChatHistoryが複数回呼び出さなっているチャットの歴史をフェッチするために、細胞
cell = STBubbleTableViewCell.init(style: .Subtitle, reuseIdentifier: cellIdentifier)
cell.backgroundColor = self.chatTableView?.backgroundColor
cell.selectionStyle = .None
cell.dataSource = self
cell.delegate = self
let chat = chatMessages[indexPath.row]
cell.textLabel?.font = UIFont.systemFontOfSize(14.0)
cell.textLabel?.text = chat.message
if(self.isGroupChat)
{
cell.detailTextLabel?.text = NSString.init(format: "%@ %@", chat.authorName, chat.messageDate.toShortTimeString()) as String
}
else
{
cell.detailTextLabel?.text = chat.messageDate.toShortTimeString()
}
cell.authorType = chat.authorType == 0 ? AuthorType.STBubbleTableViewCellAuthorTypeSelf : AuthorType.STBubbleTableViewCellAuthorTypeOther
cell.bubbleColor = chat.bubbleType == 0 ? BubbleColor.STBubbleTableViewCellBubbleColorGreen : BubbleColor.STBubbleTableViewCellBubbleColorGray
コードを表示するための
コード。この複数の通話を避けるには?
確認しましたか? https://github.com/jessesquires/JSQMessagesViewController – Hasya
私はJSQMessageViewControllerを使用していません。私はSTTableviewCellを使用して、私のテーブルビューにメッセージを表示しました。 –
scrollViewWillBeginDraggingとscrollViewDidEndDraggingコールで何を取得しようとしていますか? – iGenio