Monday, 15 September 2014

ios - Is it possible to have different table view cell row heights for different size classes? -


I am developing an application with an adaptive layout and everything until I adaptive table Visual cell heights may not be required. I am using a storyboard and I do not see any way to do it. Is this impossible mission?

If I correctly understand your question, then using your cell height size sections Adjust different font sizes; So there is a big font on a large size screen, due to which the cells must adjust accordingly. I think the only way to do this is to set different text views for specific size sections.

I have created a test app that shows in the storyboard, I added a table view controller with a custom cell. I changed the size class to wCompact hany and added a text view (IBOutlet: labelPhone) to the cell. I cell, pinned on all 4 sides of disabled scrolling text made red, and 8. The font size I changed wRegular Hany size class, and a IBOutlet other text view added (: labelPad) with the same obstacles and font size code in the table view controller to the cell with green text 30 is as follows,

  - (void ViewDidLoad {[Super ViewDidLoad]; Self.tableView.rowHeight = UITableViewAutomaticDimension; Self.tableView.estimatedRowHeight = 50; } - (zero) viewDidAppear: (BOOL) animated {[Super Viewedapper: Animated]; [Self.tableViewReloadData]; // The cell size correctly when the table view was necessary to have first appeared} - (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section {return 5; } - (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {RDCell * cell = [tableView dequeueReusableCellWithIdentifier: @ "cell" forIndexPath: indexPath]; NSString * theText = @ "Lorem ipsum dolor sit er change lamet, consectetaur cillium adipisicing pecu, SED eiusmod incididunt ut labore et dolore magna aliqua. Center veniam best advertising passion for territories, Quis Nostrud musk ullamco laboris initial ut aliquip ex ea commodo consequat tempor is. DUIs Aute voluptate velit esse in reprehenderit in irure weeds cillum dolore eu fugiat sleeps pariatur occaecat cupidatat non proident, sunt "Excepteur Sint. Cell.labelPhone.text = theText; Cell.labelPad.text = theText; Return cell; } Got  

When the iPhone would go on the simulator, I get a little red, and when you go on the iPad simulator, so I have great green text. I put the sample app here,

after editing:

Actually, I found an easy way. You can add default wany hany size class (you your Sbwuwu (text view or label) using does not require two different scenes). Attribute inspector, next to the Font field, a little "+" button on it, and you can add different font sizes for different size classes. You just have to do it Selforroattindakspath something like,

  - (UITableViewCell *) Talikadrishy: (UITableView *) Table View Selforoatindpath: (NSIndexPath *) Anukrmnikapath {RDCell * cell = [tableView DequeueReusableCellWithIdentifier: @ "cell" forInexexPath: indexPath]; Cell.textView.text = self.theData [indexPath.row]; Return cell; }  

No comments:

Post a Comment