我有一個UIToolbar視圖,其中有一個UICollectionView。UIToolBar與UICollectionView
工具欄是一個帶collectionview的文本視圖,collectionview中充滿了用戶提及。因此,如果在textview中輸入「@m」,它將顯示與字母「m」匹配的用戶名。
它曾經不是工具欄上,但我們意識到它並沒有與鍵盤的互動駁回正確駁回並將其添加到工具欄固定的。 (這將在互動屏幕中間徘徊解僱,也不會消失)
但是現在所有的用戶交互不上工作了(儘管它在IB被啓用)
這裏是工具欄的建立:
override var canBecomeFirstResponder: Bool{
return true
}
override var inputAccessoryView: UIView?{
return self.typingView
}
//裏面viewDidLoad中:
let separator = UIView(frame: CGRect(x:0 , y: 0, width: ScreenSize.width(), height: 1))
separator.backgroundColor = UIColor.lightBackgroundGrey
self.typingView.addSubview(separator)
self.typingView.isTranslucent = false
self.typingView.setShadowImage(UIImage(), forToolbarPosition: .any)
self.typingView.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default)
self.typingView.removeFromSuperview()
self.setupMentionableCollectionView() //Sets delegate and data source only
嘿謝謝你,讓工具欄的視圖始終增加高度以包括集合的高度後,它開始工作。簡單! – daredevil1234