var pet = ["dog","cat" ,"rabbit"]
这里宠物[myindex]不起作用请帮忙!
override func viewDidLoad()
{
super.viewDidLoad()
TitleLabel.text=pet[myindex]
DescLabel.text=petdesc[myindex]
myImage.image=UIImage(named : (pet[myindex] + ". jpeg"))
}
答案 0 :(得分:-1)
您在". jpeg"
中添加了一个额外的空格。那应该不存在。像这样删除它......
override func viewDidLoad()
{
super.viewDidLoad()
TitleLabel.text=pet[myindex]
DescLabel.text=petdesc[myindex]
myImage.image=UIImage(named : (pet[myindex] + ".jpeg")) // removed the space here
}