I need to have control of this method so that I can make a change in my app. But I couldn't make this implementation work, can anyone help?
Here is the Custom Renderer of my TabbedPage:
public class MainTabbedPageRenderer : TabbedRenderer, IUITabBarControllerDelegate { [Export("tabBarController:shouldSelectViewController:")] public bool ShouldSelectViewController(UITabBarController tabBarController, UIViewController viewController) { return false; } }
The breakpoint does not stop there at all.
I have the impression that it does not stop at breakpoint because TabBarController is always null, but the screen loads and performs navigations normally, I also could not make this TabBarController be filled.
You can click on tabbar items using this method:
[Export("tabBar:didSelectItem:")] public void ItemSelected(UITabBar tabbar, UITabBarItem item) { }
UITabBarController
has a property called ShouldSelectViewController
. You need to handle it directly instead of using delegate:
protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); if (ViewController != null) { ShouldSelectViewController += (tabBarController, viewController) => { return false; }; } }
Answers
UITabBarController
has a property calledShouldSelectViewController
. You need to handle it directly instead of using delegate:Thanks @LandLu !!!!!