private UITableViewCell GetCountryCell(C1AutoComplete custom, Countries item, ComboBoxItemLoadingEventArgs e) { UITableViewCell cell = e.GetReusableItemView(CellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, CellIdentifier); } CGRect rect = cell.ContentView.Frame; UIView selectedBackgroundView = new UIView(cell.Bounds); selectedBackgroundView.BackgroundColor = new UIColor((nfloat)(0 / 255.0), (nfloat)(122.0 / 255.0), (nfloat)(255.0 / 255.0), (nfloat)1.0); cell.SelectedBackgroundView = selectedBackgroundView; foreach (UIView view in cell.ContentView.Subviews) { view.RemoveFromSuperview(); } UIImageView imageView = new UIImageView(new CGRect(4, 0, 48, 48)); NSString imagePath = new NSString("Images/" + (NSString)item.Name.ToLower() + ".png"); imageView.Image = new UIImage(imagePath); cell.ContentView.Add(imageView); UILabel label = new UILabel(new CGRect(65, 10, rect.Size.Width - 40, rect.Size.Height / 2)); label.Text = item.Name; cell.ContentView.Add(label); return(cell); }
private UITableViewCell GetYoutubeCell(C1AutoComplete filterDropdown, YouTubeVideo video, ComboBoxItemLoadingEventArgs e) { UITableViewCell cell = e.GetReusableItemView(YouTubeCellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Subtitle, YouTubeCellIdentifier); } LoadImageInBackground(cell.ImageView, video.Thumbnail); cell.TextLabel.Text = video.Title; cell.DetailTextLabel.Text = video.Description; return(cell); }
private UITableViewCell GetCountryCell(C1AutoComplete custom, Countries item, ComboBoxItemLoadingEventArgs e) { UITableViewCell cell = e.GetReusableItemView(CellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, CellIdentifier); } CGRect rect = cell.ContentView.Frame; UIView selectedBackgroundView = new UIView(cell.Bounds); selectedBackgroundView.BackgroundColor = new UIColor((nfloat)(0 / 255.0), (nfloat)(122.0 / 255.0), (nfloat)(255.0 / 255.0), (nfloat)1.0); cell.SelectedBackgroundView = selectedBackgroundView; foreach (UIView view in cell.ContentView.Subviews) { view.RemoveFromSuperview(); } const int padding = 4; UIImageView imageView = new UIImageView(new CGRect(padding, 0, 48, 48)); UILabel label = new UILabel(new CGRect(65, 10, rect.Size.Width - 40, rect.Size.Height / 2)); imageView.TranslatesAutoresizingMaskIntoConstraints = false; label.TranslatesAutoresizingMaskIntoConstraints = false; NSString imagePath = new NSString("Images/" + (NSString)item.Name.ToLower() + ".png"); imageView.Image = new UIImage(imagePath); cell.ContentView.Add(imageView); label.Text = item.Name; cell.ContentView.Add(label); // anchor image to parent cell imageView.LeadingAnchor.ConstraintEqualTo(cell.LeadingAnchor, (nfloat)(padding)).Active = true; imageView.TopAnchor.ConstraintEqualTo(cell.TopAnchor).Active = true; imageView.BottomAnchor.ConstraintEqualTo(cell.BottomAnchor).Active = true; // anchor label follow to image label.LeadingAnchor.ConstraintEqualTo(imageView.LeadingAnchor, (nfloat)(padding + imageView.Frame.Width)).Active = true; label.TopAnchor.ConstraintEqualTo(cell.TopAnchor).Active = true; label.BottomAnchor.ConstraintEqualTo(cell.BottomAnchor).Active = true; return(cell); }