UIButtonのタイトルテキストを変更しようとしていますが、機能しません。私はUITableView
にそれを持っています。ボタンのタイトルのテキストを変更することができません
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let imageCell = tableView.dequeueReusableCellWithIdentifier("imageCell", forIndexPath: indexPath) as! StoryCell
let videoCell = tableView.dequeueReusableCellWithIdentifier("videoCell", forIndexPath: indexPath) as! StoryCell
let blankCell = tableView.dequeueReusableCellWithIdentifier("blankCell", forIndexPath: indexPath) as! StoryCell
if (userFile[indexPath.item].url!.rangeOfString(".jpeg") != nil) {
print("imageCell: \(userFile[indexPath.row].url)")
imageCell.viewstoryButton.setTitle("Vis bildeeee - \(self.createdAt[indexPath.row].timeAgo)", forState: UIControlState.Normal)
imageCell.viewstoryButton.titleLabel?.textColor = UIColor.redColor()
return imageCell
}
if (userFile[indexPath.row].url!.rangeOfString(".mp4") != nil) {
print("videoCell: \(userFile[indexPath.row].url)")
videoCell.viewstoryButton.setTitle("Vis video - \(self.createdAt[indexPath.row].timeAgo)", forState: UIControlState.Normal)
return videoCell
}
else{
print("blankCell")
return blankCell
}
}
そして、私は3個のプロトタイプ細胞があります:imageCell
、videoCell
とblankCell
をこれは、それがどのように見えるかです。
これらはすべてStoryCell
に接続されていますが、ボタンは表示されますが、テキストまたは色は変更されません。何か案は?
これらのボタンは、セルに表示されているというカスタムセルライブラリに接続されている場合も、アプリケーションを実行するときに、確認することができます? ifブロック呼び出しかどうかを確認してください。 – Lion
ブレークポイントを設定して、それらの行が呼び出されているかどうかを確認します。また、あなたのコードの流れに合わせてreloadDataが必要かもしれません。 –
@Lionはい、表示されます。そして、ifブロックが呼び出すのは、imageCellとvideoCellの両方から出力されるためです。しかし、何か変です。 Parse here:http://i63.tinypic.com/1zd7lzc.jpgには、2つの画像と1つのビデオが含まれていますが、アプリケーションを実行すると、2つのテーブルビューのビデオセルと1つのビデオが表示されます画像のセル..任意の手がかり? –