public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) { if (editingStyle == UITableViewCellEditingStyle.Delete) { Model.Punch punch = punchItems.ElementAt(indexPath.Row); this.punchItems.Remove(punch); tableView.ReloadData(); } }
// public static PunchCell Create () // { // return (PunchCell)Nib.Instantiate (null, null) [0]; // } public void UpdateCell(InspectionViewController parentController, UITableView optionsTableView, NSIndexPath indexPath, List <Model.Punch> punchItems) { try { ResetUIView(); this.parentController = parentController; this.optionsTableView = optionsTableView; this.indexPath = indexPath; Model.Punch punchItem = punchItems.ElementAt(indexPath.Row); this.punch = punchItem; this.punchItems = punchItems; foreach (var byteImage in this.punch.punchImages) { imagesList.Add(ByteArrayToImage(byteImage)); } if (Source == null) { Source = new PunchDataSource(imagesList, this); } else { Source.itemsList = imagesList; } imagesCollectionView.DataSource = Source; imagesCollectionView.ReloadData(); //if the heading is addRow if (true == shouldInsertRow) { Model.Punch punch = new Model.Punch(); punch.punchHeading = "Item " + indexPath.Row; punchItems.Add(punch); optionsTableView.BeginUpdates(); optionsTableView.InsertRows(new NSIndexPath[] { NSIndexPath.FromRowSection(indexPath.Row, indexPath.Section) }, UITableViewRowAnimation.None); optionsTableView.EndUpdates(); } punchHeadingLabel.Font = UIFont.FromName("Helvetica", 17f); punchHeadingLabel.TextColor = UIColor.FromRGB(186, 190, 194); punchTakePicBtn.Layer.CornerRadius = 5f; punchTakePicBtn.Layer.BackgroundColor = UIColor.FromRGB(18, 74, 143).CGColor; punchTakePicBtn.Layer.BorderWidth = 0.5f; punchTakePicBtn.SetTitleColor(UIColor.White, UIControlState.Normal); punchTakePicBtn.TouchUpInside -= BtnTakePic_TouchUpInside; punchTakePicBtn.TouchUpInside += BtnTakePic_TouchUpInside; punchTextView.Layer.CornerRadius = 5f; punchTextView.Layer.BorderColor = UIColor.FromRGB(186, 190, 194).CGColor; punchTextView.Layer.BorderWidth = 0.5f; if (tap != null) { this.RemoveGestureRecognizer(tap); } tap = new UITapGestureRecognizer(); tap.AddTarget(tapAction); this.AddGestureRecognizer(tap); //punchImagesScrollView.Hidden = false; punchTakePicBtn.Hidden = false; punchTextView.Hidden = false; punchHeadingLabel.Hidden = false; int showHeadingRowNumber = indexPath.Row + 1; string headingString = "Item " + showHeadingRowNumber; punchHeadingLabel.Text = headingString; punchTextView.Text = punchItem.punchDescription; var textDelegate = new PunchTextViewDelegate(this); punchTextView.WeakDelegate = textDelegate; LoadPunchView(); shouldInsertRow = false; } catch (Exception ex) { Debug.WriteLine("Exception Occured in UpdateCell method due to " + ex.Message); } }