我正在努力让每个单元都能被点击并将它们带到一个新的视图控制器。
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as UICollectionViewCell
let cellLabels = cell.viewWithTag(1) as! UILabel
cellLabels.text = arrayOfCellLabel[indexPath.row]
return cell
} // # Of Cells
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return arrayOfCellLabel.count
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0 {
self.performSegueWithIdentifier("box", sender: self)
}
if indexPath.row == 1 {
self.performSegueWithIdentifier("box1", sender: self)
}
}
答案 0 :(得分:2)
您需要使用集合视图委托而不是表视图的委托
@model IEnumerable<Titan.Models.customer>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.first_name)
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.first_name)
</td>
</tr>
}
</table>