Objective c Swift中UITableViewController中的自定义单元格
如果我在UITableViewController UILabel、UIImageView等中放入一个prototype单元格并进行输出,那么我会得到一个错误:连接不能将prototype对象作为其目标 我决定做不同的事情:我把一个细胞原型,我需要的元素分配给每个标签。现在我尝试使用标记显示信息。在Objective-C中,它看起来像这样:Objective c Swift中UITableViewController中的自定义单元格,objective-c,uitableview,swift,custom-cell,Objective C,Uitableview,Swift,Custom Cell,如果我在UITableViewController UILabel、UIImageView等中放入一个prototype单元格并进行输出,那么我会得到一个错误:连接不能将prototype对象作为其目标 我决定做不同的事情:我把一个细胞原型,我需要的元素分配给每个标签。现在我尝试使用标记显示信息。在Objective-C中,它看起来像这样: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Locatio
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LocationCell"];
Location *location = [_locations objectAtIndex:indexPath.row];
UILabel *nameLabel = (UILabel*) [cell viewWithTag:101];
nameLabel.text = location.title;
UILabel *date = (UILabel*) [cell viewWithTag:102];
date.text = location.place;
我不明白我是怎么在Swift上做的。请帮忙。我这样试过,但没有成功:
var postImage:UIImageView = UIImageView()
postImage.image = UIImage(data: NSData(contentsOfURL: NSURL.URLWithString(wordpressArray[indexPath!.row].url)))
cell!.viewWithTag(103)
var postTitle:UILabel = UILabel()
postTitle.text = wordpressArray[indexPath!.row].post_title
cell!.viewWithTag(101)
您似乎已尝试将UILabel和UIImageView附加到UITableViewCells默认属性上
从UITableViewCell声明您自己的自定义子类,并命名您自己的属性,最好不要像super类那样请显示您已经进行的尝试。