我有近30個單元被佔用在我的UITableView中。我使用故事板模式創建表格。當我試圖調用我選擇其註冊爲0的單元格時,無論我選擇了哪個單元格。如何讓我的手機註冊我推送的確切號碼並將其插入到我的當前標籤中? 這裏是我迄今爲止我的UITableView單元沒有給我正確的信息
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return catNames.count;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel?.text = catNames[indexPath.row]
cell.textLabel?.textColor = UIColor.whiteColor()
cell.backgroundColor = UIColor(red: 0x0e/255, green: 0x1b/255, blue: 0x35/255, alpha: 1.0)
cell.textLabel?.textAlignment = NSTextAlignment.Left
cell.textLabel?.lineBreakMode = NSLineBreakMode.ByTruncatingMiddle
cell.textLabel?.adjustsFontSizeToFitWidth = true
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
currentTag = tableView.tag
println("This is the \(currentTag)")
self.performSegueWithIdentifier("table2Segue", sender:self)
}
使用'currentTag = indexPath.row'。除非將其設置爲其他值,否則您的'tableView'將始終具有'tag'作爲'0'。 – sikhapol 2015-02-11 18:31:01