我有一个数组,我想删除一堆索引
var arr = [0,1,2,3,4,5,6]
var rmIndices = [1,4,5]
Run Code Online (Sandbox Code Playgroud)
从arr删除指数1,4,5的最佳方法是什么?
我正在下载一些图像并将它们插入到我的 UICollectionView 中
这些是我的班级成员
var myItems:[UIImage] = []
var myView: UICollectionView?
Run Code Online (Sandbox Code Playgroud)
我有一个接收 img:UIImage 对象的计时器函数。我将其插入到我的 UICollectionView 中,如下所示
self.myItems.insert(img, atIndex: self.myItems.count)
var count:Int? = self.myView?.numberOfItemsInSection(0)
var index:NSIndexPath = NSIndexPath(forRow: count!, inSection: 0)
self.myView?.insertItemsAtIndexPaths([index])
Run Code Online (Sandbox Code Playgroud)
我也有这个功能:
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.myItems.count;
}
Run Code Online (Sandbox Code Playgroud)
和这个:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as MyCollectionViewCell
cell.backgroundColor = UIColor.orangeColor()
cell.textLabel.text = "Text \(indexPath.row)"
cell.imageView.image = myItems[indexPath.row]
cell.backgroundView = UIImageView(image: UIImage(named: "cellbg"))
return cell
} …Run Code Online (Sandbox Code Playgroud)