GÜNCELLEME !!! Varsayılan hücre altyazısının hücreyi otomatik hale getirmesi için, iki etiketin satır sayısını 0 olarak ayarlamanız gerekir. Aksi halde çalışmaz. Tuhaf.
cell.textLabel?.numberOfLines = 0
cell.detailTextLabel?.numberOfLines = 0
yapabilirsiniz oto boyutlandırma varsayılan sytled hücreleri. En basit haliyle aşağıdaki koda sahibim. Varsayılan stillenmiş altyazı hücresini otomatik olarak yeniden boyutlandırma.
class ViewController: UIViewController {
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 44
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension ViewController: UITableViewDataSource {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
let thisHelpArticle = "Lorem ipsum dolor sit amet, vel porttitor blandit, aliquam tristique vestibulum, enim vel eros fames id, in gravida vestibulum gravida tempor, et vel libero sed mauris. Suspendisse ut placerat viverra dictum, ante ante vel ut vestibulum sollicitudin phasellus. Dictumst adipiscing adipiscing nisl, fusce ut. Ante wisi pellentesque, et aliquam rhoncus eget convallis quam voluptate, ut nec quis, sodales ullamcorper elementum pellentesque sagittis vitae, dolor justo fermentum amet risus. Eu placerat ultricies. Ipsum sodales, massa elit, in neque, sed penatibus gravida, cursus eget. Ut tincidunt at eu, wisi dis vel penatibus eget, volutpat ligula vel tortor morbi feugiat, dui et eiusmod dis sociis. Iaculis lorem molestie laoreet sit, orci commodo, fusce vestibulum sapien, quisque egestas maecenas sed rem in nisl."
cell.textLabel?.numberOfLines = 0
cell.detailTextLabel?.numberOfLines = 0
cell.textLabel!.text = thisHelpArticle
cell.detailTextLabel!.text = thisHelpArticle
return cell
}
}
extension ViewController: UITableViewDelegate {
}
Daha fazla bilgiye ihtiyacımız var. Lütfen hücreleri nasıl doldurduğunuzu gösterin. Artı, autolayout kullanıyor musunuz? – ozgur
Belirtildiği gibi, altyazı stiline sahip varsayılan bir hücreye sahip olan bir uitableviewcontroller, bu nedenle otomatik ekleme ekleyemezsiniz, – magnuskahr
üzerindeki popülasyonu ekleyecektir. Hücreyi döndürmeden önce 'cell.layoutIfNeeded()' diyebilir misiniz? – ozgur