private static UIView GetSuperview(this UIBarButtonItem item, UIView view) { var toolbar = view as UIToolbar; if (toolbar != null && toolbar.Items.Any(b => b == item)) { return(view); } foreach (var subview in view.Subviews) { var superview = item.GetSuperview(subview); if (superview != null) { return(superview); } } return(null); }
private void ActionSheetClicked(object sender, UIButtonEventArgs e) { if (e.ButtonIndex < menuButtons.Count) { var item = TouchFactory.GetNativeObject <UIBarButtonItem>(menuButtons[(int)e.ButtonIndex], "menuButton"); if (item != null && item.Target != null && item.Action != null) { UIViewController obj = null; if (parentView != null) { obj = parentView.GetSuperview <IListView>() as UIViewController; } else if (parentItem != null) { obj = parentItem.GetSuperview(); } item.Target.PerformSelector(item.Action, obj, 0); } } }
public static UIViewController GetSuperview(this UIBarButtonItem item) { foreach (var stack in iFactr.Core.PaneManager.Instance.OfType <UINavigationController>().Where(s => s.NavigationBar.TopItem != null)) { if ((stack.NavigationBar.TopItem.RightBarButtonItems != null && stack.NavigationBar.TopItem.RightBarButtonItems.Any(b => b == item)) || (stack.NavigationBar.TopItem.LeftBarButtonItems != null && stack.NavigationBar.TopItem.LeftBarButtonItems.Any(b => b == item))) { return(stack.TopViewController); } } foreach (var controller in iFactr.Core.PaneManager.Instance.OfType <UINavigationController>().Select(nc => nc.TopViewController)) { if (controller != null && item.GetSuperview(controller.View) != null) { return(controller); } } return(null); }