UICollectionViewDelegate 与 searchbar 一起作用时,两个代理方法:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {}
的内容需要与 searchbar.text 同步。
只有这两个方法一起更新后,collectionview才会对search内容不存在的情况做出正确反应,即显示空的collectionview。
否则,在search内容为空时,会出现 array index out of bound 报错。