【发布时间】:2015-05-16 15:50:32
【问题描述】:
事情是这样的:
我实现了一个带有自定义单元格的 UITableViewController..
然后我用viewcontroller to viewcontroller替换了自动转场cell to viewcontroller(故事板)。
来自我的 UITableViewController 的代码:
// MARK: - Tableview managment
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var lobbycell = tableView.dequeueReusableCellWithIdentifier("lobbycell") as! LobbyTableViewCell
let row = indexPath.row
if let channel = lobbies[row].lobbyName {
lobbycell.lobbynameLabel.text = channel
}
if let usercount = lobbies[row].users?.count {
lobbycell.usercountLabel.text = "Anzahl Spieler: \(usercount)"
}
if let host = lobbies[row].host?.username {
lobbycell.hostnameLabel.text = "Host: \(host)"
}
return lobbycell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return lobbies.count
}
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
let selectedLobby = lobbies[indexPath.row]
var loading = MBProgressHUD.showHUDAddedTo(self.view, animated: true)
PFLobby.joinLobbyInBackgroundWithBlock(selectedLobby, user: PFUser.currentUser()!) { (success, error) -> Void in
loading.hide(true)
if success {
self.performSegueWithIdentifier("joinLobby", sender: self)
} else {
}
}
}
现在问题来了:
如果我单击一个单元格,它将变为灰色(如选中)但不会调用 didDeselectRowAtIndexPathfunc..
只有当我点击另一个单元格时,它才会调用 didDeselectRowAtIndexPath 带有灰色(如选中)单元格的 indexPath。
【问题讨论】:
-
您的意思是/期望使用
didSelectRowAtIndexPath而不是didDeselectRowAtIndexPath? (选择与取消选择) -
Omg xD 当然......对不起,自动完成谢谢......
标签: ios uitableview swift