Как я могу использовать то, что у меня есть в прототипе HomePagec и повторно использовать его в пользовательском профилеке? Это все равно, что иметь домашнюю страницу данных, а затем видеть данные отдельных пользователей, следовательно, пользовательский, но тот же макет, потому что я думаю, что это избыточно, выполнять 2 идентичные просмотры таблиц.
Код: Выделить всё
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "HomePageTVC", for: indexPath) as! HomePageTVC
cell.post.text = Posts[indexPath.row]
cell.fullname.setTitle(FullName[indexPath.row],for: UIControlState.normal)
cell.fullname.tag = indexPath.row
cell.fullname.addTarget(self, action: #selector(HomePageC.Fullname_Click(sender:)), for: .touchUpInside)
cell.comments.setTitle(Comments[indexPath.row],for: UIControlState.normal)
cell.comments.tag = indexPath.row
cell.votes.setTitle(Votes[indexPath.row],for: UIControlState.normal)
cell.votes.tag = indexPath.row
cell.time.text = Times[indexPath.row]
cell.shares.setTitle(Shares[indexPath.row],for: UIControlState.normal)
cell.shares.tag = indexPath.row
cell.location.text = Locations[indexPath.row]
return cell
}
< /code>
UserProfileCКод: Выделить всё
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "UserProfileTVC", for: indexPath) as! HomePageTVC
cell.post.text = Posts[indexPath.row]
cell.fullname.setTitle(FullName[indexPath.row],for: UIControlState.normal)
cell.fullname.tag = indexPath.row
cell.fullname.addTarget(self, action: #selector(HomePageC.Fullname_Click(sender:)), for: .touchUpInside)
cell.comments.setTitle(Comments[indexPath.row],for: UIControlState.normal)
cell.comments.tag = indexPath.row
cell.votes.setTitle(Votes[indexPath.row],for: UIControlState.normal)
cell.votes.tag = indexPath.row
cell.time.text = Times[indexPath.row]
cell.shares.setTitle(Shares[indexPath.row],for: UIControlState.normal)
cell.shares.tag = indexPath.row
cell.location.text = Locations[indexPath.row]
cell.vote_status.text = Votes[indexPath.row]
return cell
}
< /code>
I tried to cast it to HomePageПодробнее здесь: https://stackoverflow.com/questions/431 ... itableview
Мобильная версия