ios - How do I make a custom table cell work with dynamically sized labels within? -


I'm not sure that there is an excellent way to show a problem with multiple files in an encoded project, so please forgive me Two if this is not the best way - and please tell me what else I can show!

In any case, I have a custom table view that is displayed with a nib (.xib), and the dynamic dynamic height is displayed in the custom table view labeled everything very well Except for the fact that table cell height is not suitable for the increased height of the overall elements.

What can I see that the row height value for the table view is being used as a complete, and I'm not sure how to override it I set it as 200 And it is fixed for each table, even if the content exceeds that height:

I am using automatic layout, which is very much in the middle of the cell elements. Good working ... this is the only cell height that is not being set.

Class EventTableViewCell: UITableViewCell {func loadItem (#date: string, title: string, description: string, image: UIImage) {dateLabel.text = date titleLabel.text = title eventImage.image = Image eventDescription.text = description titleLabel.setTranslatesAutoresizingMaskIntoConstraints (Wrong) TitleLabel. NumberOfLines = 0 self.contentView.addSubview (titleLabel) eventDescription.setTranslatesAutoresizingMaskIntoConstraints (incorrect) eventDescription NumberOfLines = 0self.contentView.addSubview (Event Description)} @Iboutlet WeirdVarVar Event Image: UIImageView! @IBOTTLET WEATHER WEAR DEATH LABEL: UILABLE! @IBOutlet weak variant label: UILBL! @IBOutlet weak var event description: UILabel!

and manage the data that is class:

  Category contact: UITableViewController (override the awakeFromNib function) {super.awakeFromNib () // Start Code} , UITableViewDataSource, UITableViewDelegate {var EventData: [AnyObject] = [] Override Funk Table View (Table View: UITableView, numberOfRowsInSection section: Int) - & gt; Int {return eventData.count} Override funk tableview (Tableview: UITABLE VIEW, SELLFORROUTENDExpath INDEXPath: NS INDEX) - & gt; UITableViewCell {let cell = tableView.dequeueReusableCellWithIdentifier ("customcell", forIndexPath: indexPath) as EventTableViewCell if (eventData.count! = 0) {var event: AnyObject? = EventData [indexPath.row] If unwrappedEvent: AnyObject = event {Enter} EventTitle = unwrappedEvent ["title"]? Give string as eventDate = unwrappedEvent ["date"]? Let string be an event in the form of the description = unloaded event ["description"] as the string in the event image = unlocked event ["image"]? UIImage if (eventImage = zero!) {Cell.loadItem (Date: EVENTDATE !, Title: EVENTTITLE !, Description: eventDescription, Image: eventImage)} else {know testImage: UIImage = UIImage (name: "test image.png") Cell.loadItem (Date: EVENTTATE !, Title: EVENTTITLE !, Description: eventDescription, Image: testImage)}}} Return Cell} viewDidLoad () {super.viewDidLoad () arrow Nib = UINib (nibName Function Override: "CustomTableViewCell", Bundle: zero) tableView.registerNib (nib, forCellReuseIdentifier: "customCell") Manager = AFHTTPRequestOperationManager () manager.GET ("http: // [Mary-json-file] .json", parameter: zero, success: {( Operation: AFHTTPRequestOperation, responseObject:! AnyObject) in println! ("JSON:" + responseOb Ject.description) self.eventData = responseObject ["Events"] [AnyObject] ew.reloadData ()}, as self.tableVi Failure: {(operation: AFHTTPRequestOperation, Error: NSError) in println ("Error:" + Error.localizedDescription)}}}  

I'm not sure what can I do to make cell height work dynamically at this point. I have just tried everything about any help would be greatly appreciated, and then, please tell me if I have some more code, like show my code etc.

Thank you very much before!

I have noticed that in your contact class, you can call tableView (_ tableView: UITableView, heightForRowAtIndexPath Index Path: NSIndexPath) Method. I suspect that if you do this, the code will work.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -