Как я могу увеличить высоту для определенной ячейки (в UITableView) в определенном разделе (второй раздел в моем случае, где это изображение со Swift).Я не знаю, возможно ли установить автоматическое изменение размера моей ячейки, но на данный момент я хочу только увеличить размер этой ячейки, потому что внутри я ничего не вижу.Мое приложение выглядит так:
Я хочу увеличить размер той ячейки, в которой находится WebView.
Вот мой код:
extension DetailsViewController: UITableViewDelegate, UITableViewDataSource{
func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0: return 6
case 1: return 1
default:
return 0
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section{
// Section 1: Repository Details
case 0:
let cell = detailsTableView.dequeueReusableCell(withIdentifier: "repoDetailsCell", for: indexPath) as! DetailsTableViewCell
// Set each row from first section
switch indexPath.row{
case 0:
cell.avatarImageView.downloadedFrom(link: "\(selectedRepo.owner.avatarURL)")
if indexPath.row == 0{
self.detailsTableView.rowHeight = 60
}
cell.textLabel?.isHidden = true
cell.detailTextLabel?.text = selectedRepo.description
cell.textLabel?.numberOfLines = 0
cell.detailTextLabel?.numberOfLines = 0
return cell
case 1:
cell.textLabel?.text = selectedRepo.description
cell.textLabel?.numberOfLines = 0
cell.detailTextLabel?.isHidden = true
return cell
case 2:
cell.textLabel?.text = "Open Issues"
cell.detailTextLabel?.text = String(selectedRepo.openIssuesCount)
return cell
case 3:
cell.textLabel?.text = "Forks"
cell.detailTextLabel?.text = String(selectedRepo.forksCount)
return cell
case 4:
cell.textLabel?.text = "Watchers"
cell.detailTextLabel?.text = String(selectedRepo.watchersCount)
return cell
case 5:
cell.textLabel?.text = "URL"
cell.detailTextLabel?.text = selectedRepo.htmlURL
cell.detailTextLabel?.textColor = UIColor.blue
cell.detailTextLabel?.numberOfLines = 0
return cell
default:
return cell
}
// Section 2: Webview
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "repoWebviewCell", for: indexPath) as! DetailsTableViewCell
// Set the WebView from Section 2
switch indexPath.row{
case 0:
UIWebView.loadRequest(cell.webView)(NSURLRequest(url: NSURL(string: "\(selectedRepo.htmlURL)/blob/master/README.md")! as URL) as URLRequest)
return cell
default:
return cell
}
default: return UITableViewCell()
}
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 200
}
}