0
我正在制作一个表格,用户可以按下并从按下的单元格中获取更详细的信息。不过,我在如何使UIimage发挥作用方面遇到了一些麻烦。swift如何将图像传递给可点击的tableview单元格?
我的代码如下:
let shotMatchSegue = "ShowMatchSegue"
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == shotMatchSegue,
let destination = segue.destinationViewController as? MatchViewController,
matchIndex = recentMatchesTableView.indexPathForSelectedRow?.row
{
destination.matchChampionImage = UIImage(named: "\(championsPlayed[matchIndex])_Splash_Tile_0")
destination.matchType = gameType[matchIndex]
}
}
我MatchViewController,我有以下几点:
@IBOutlet弱VAR gameMatchChampionIcon:UIImageView的!
@IBOutlet weak var gameMatchType: UILabel!
var matchType = String()
var championIcon = String()
override func viewWillAppear(animated: Bool) {
gameMatchChampionIcon.image = UIImage()
gameMatchType.text = matchType
}
我能想象这是最有可能的,我建立了我的gameMatchChampionIcon.image =的UIImage()错误的情况。所以我想知道什么是正确的方式来设置,如果我想传递图像到UIimage
感谢您的帮助!
YAY它的作品!谢谢你,朋友! – user3175707