public void showImageAtIndexPath(NSObject sender, HomepwnerItemCell cell) { NSIndexPath indexPath = TableView.IndexPathForCell(cell); Console.WriteLine("Going to show the image for {0}", indexPath); // Get the item for the index path BNRItem i = BNRItemStore.allItems[indexPath.Row]; string imageKey = i.imageKey; // If there is no image, we don't need to do anything if (imageKey == null || imageKey == "") { return; } UIImage img = BNRImageStore.imageForKey(imageKey); // Create a new ImageViewController and set its image ImageViewController ivc = new ImageViewController(); ivc.Image = img; ivc.PopoverSize = new CGSize(600, 600); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { // Make a rectangle that the frame of the button relative to our table view UIButton btn = sender as UIButton; CGRect rect = View.ConvertRectFromView(btn.Bounds, btn); // Present a 600 x 600 popover from the rect imagePopover = new UIPopoverController(ivc); imagePopover.PopoverContentSize = ivc.PopoverSize; imagePopover.DidDismiss += (object pSender, EventArgs e) => { imagePopover.Dismiss(true); imagePopover = null; }; imagePopover.PresentFromRect(rect, View, UIPopoverArrowDirection.Any, true); } else { this.NavigationController.PushViewController(ivc, true); } }
public void showImageAtIndexPath(NSObject sender, HomepwnerItemCell cell) { NSIndexPath indexPath = TableView.IndexPathForCell(cell); Console.WriteLine("Going to show the image for {0}", indexPath); // Get the item for the index path BNRItem i = BNRItemStore.allItems[indexPath.Row]; string imageKey = i.imageKey; // If there is no image, we don't need to do anything if (imageKey == null || imageKey == "") return; UIImage img = BNRImageStore.imageForKey(imageKey); // Create a new ImageViewController and set its image ImageViewController ivc = new ImageViewController(); ivc.Image = img; ivc.PopoverSize = new CGSize(600, 600); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { // Make a rectangle that the frame of the button relative to our table view UIButton btn = sender as UIButton; CGRect rect = View.ConvertRectFromView(btn.Bounds, btn); // Present a 600 x 600 popover from the rect imagePopover = new UIPopoverController(ivc); imagePopover.PopoverContentSize = ivc.PopoverSize; imagePopover.DidDismiss += (object pSender, EventArgs e) => { imagePopover.Dismiss(true); imagePopover = null; }; imagePopover.PresentFromRect(rect, View, UIPopoverArrowDirection.Any, true); } else { this.NavigationController.PushViewController(ivc, true); } }