我是swift的新手,正在寻找我正在努力编写的这个特殊功能的帮助。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier {
switch identifier {
case "Show Album":
let albumViewController = segue.destination as! AlbumViewController
let albumImageView = (sender as AnyObject).view as! UIImageView
if let index = index(of: covers, albumImageView) {
let album = Album(index: index)
albumViewController.album = album
}
在线:
let albumImageView = (sender as AnyObject).view as! UIImageView
获取错误:
ambiguous use of 'view'
感谢任何帮助。
答案 0 :(得分:0)
sender as AnyObject
强制sender
输入AnyObject
。 AnyObject
没有名称为view
的属性,因此在其上调用.view
没有意义。