2
我在單元格和文本右側也有一個按鈕。文本與按鈕重疊。我希望文本在觸摸按鈕之前進入下一行。我會怎麼做?任何方法來解決按鈕和文本的重疊?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = table.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! ProfileMusicCell
cell.customtitle.text = ret[indexPath.row]
cell.customartist.text = ter[indexPath.row]
cell.customtitle.font = UIFont(name: "Lombok", size: 22)
cell.customtitle.textColor = UIColorFromRGB("4A90E2")
cell.customartist.font = UIFont(name: "Lombok", size: 16)
cell.customartist.textColor = UIColor.blackColor()
cell.playbutton.tag = indexPath.row
cell.playbutton.addTarget(self, action: "playmusic:", forControlEvents: .TouchUpInside)
cell.contentView.addSubview(playButton)
cell.textLabel?.numberOfLines = 0;
cell.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping
cell.backgroundColor = UIColor.clearColor()
return cell
}
func playmymusic(sender: UIButton!) {
let playButtonrow = sender.tag
print(ret[playButtonrow])
print(ter[playButtonrow])
}
你有沒有嘗試重新設置按鈕的約束,並重新插入它們基於按鈕的位置?我有一個導航欄和一個視圖類似的問題,經過一個下午的搜索,我發現這是唯一的解決方案。 – Korpel
我不明白你的意思 – xxtmanxx
''playButton.frame = CGRectMake(230,20,100,100)'''''''''''''''''''',我的意思是你沒有利用自動佈局。如果用戶更改設備問題將會發生 – Korpel