【发布时间】:2016-07-13 22:23:05
【问题描述】:
我有一个应用程序,它在一个 UICollectionView 中有 12 个单元格。我希望当用户单击每个单元格时,它应该在一个 WebView 中打开相应的网站,就像第一个应该打开 facebook 另一个应该打开 twitter 等。
在UICollectionView 中创建单元格的代码如下,我需要知道如何创建一个可能是 url 的数组并将其传递给所有单元格以显示网站。
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.category.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionview.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CollectionViewCell1
cell.imageopenview.image = self.imagearray[indexPath.row]
cell.titlelabel .text = self.category[indexPath.row]
return cell
【问题讨论】:
标签: ios iphone swift uiwebview