29,031
社区成员
发帖
与我相关
我的任务
分享
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{
NSLog("\(indexPath.row)")
let collectionCell = collectionView.dequeueReusableCellWithReuseIdentifier("collectionCellLocation", forIndexPath: indexPath) as UICollectionViewCell
let cityLocationButton = collectionCell.viewWithTag(1) as! UIButton
let autoLocationButton = collectionCell.viewWithTag(2) as! UIButton
if indexPath.row > 0 {
NSLog("1111111")
autoLocationButton.hidden = true
cityLocationButton.setTitle(searchCityList[indexPath.row-1], forState: UIControlState.Normal)
}else{
cityLocationButton.hidden = true
}
//添加手动定位点击事件
cityLocationButton.tag = indexPath.row
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "clickForCityName:")
cityLocationButton.addGestureRecognizer(tapGestureRecognizer)
//添加自动定位点击事件
autoLocationButton.tag = indexPath.row
autoLocationButton.addTarget(self, action: "clickAutoLocation:", forControlEvents: UIControlEvents.TouchUpInside)
return collectionCell
}
let cityLocationButton = collectionCell.viewWithTag(1) as! UIButton