How do I databind a ColumnDefinition’s Width or RowDefinition’s Height?

Create a IValueConverter as follows: public class GridLengthConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { double val = (double)value; GridLength gridLength = new GridLength(val); return gridLength; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { GridLength val = (GridLength)value; return val.Value; } } You can … Read more

Dynamic Height Issue for UITableView Cells (Swift)

Try This: func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return UITableViewAutomaticDimension } EDIT func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return UITableViewAutomaticDimension } Swift 4 func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { return UITableViewAutomaticDimension } Swift 4.2 func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { return … Read more

Setting custom UITableViewCells height

Your UITableViewDelegate should implement tableView:heightForRowAtIndexPath: Objective-C – (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return [indexPath row] * 20; } Swift 5 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return indexPath.row * 20 } You will probably want to use NSString‘s sizeWithFont:constrainedToSize:lineBreakMode: method to calculate your row height rather than just performing some silly … Read more

Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

TL;DR: Don’t like reading? Jump straight to the sample projects on GitHub: iOS 8 Sample Project – Requires iOS 8 iOS 7 Sample Project – Works on iOS 7+ Conceptual Description The first 2 steps below are applicable regardless of which iOS versions you are developing for. 1. Set Up & Add Constraints In your … Read more

tech