We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Ability for each Tab to be linked to a separate ViewController

Hi there,

I believe each TabItem expects a UIView in its Content prop. What I'm wondering is whether it's possible for each TabItem to be linked to a UIViewController instead (that host a UIView). The reason being each of my TabItems will have a separate ViewController. 

Looking forward to getting clarification.

🤞

Thanks!

Bardi

5 Replies

HM Hemalatha Marikumar Syncfusion Team February 5, 2020 01:40 PM UTC

Hi Bardi Golriz, 
  
Greetings from the Syncfusion. 
  
We would like to let you know that we have checked the reported query and that it is not possible to link to the ViewController in the current implementation because the SfTabView is implemented in such a way that it accepts only the UIView. 
 
Please revert us for further investigation. 
 
Regards,
Hemalatha M. 



BG Bardi Golriz February 6, 2020 12:58 PM UTC

Thanks for the response and clarification. That's a shame. Are there any plans to extend the control so that it supports multiple view controllers? At present, it does limit its capability. That said, would a workaround be to have a container view in each view and for that to link to its own view controller? I imagine that could work but would appreciate your confirmation on this (and whether it's recommended).



SP Sakthivel Palaniyappan Syncfusion Team February 7, 2020 05:58 PM UTC

Hi Bardi,

Thanks for your update.

Since Content property of SfTabItem is of type UIView we could not set a Viewcontroller to it. However, the View Property of the ViewController is of the type UIView and hence can be set to the Content property of SfTabItem. We have provided a sample illustrating the same. Please do check if it satisfies your requirement.

Code snippet: 
  public override void ViewDidLoad() 
        { 
            base.ViewDidLoad(); 
            TabItem1Controller tabItem1Controller = new TabItem1Controller(); 
            TabItem2Controller tabItem2Controller = new TabItem2Controller(); 
            var tabView = new SfTabView(); 
            tabView.Frame = new CGRect(0, 0, View.Frame.Width, View.Frame.Height); 
            View.AddSubview(tabView); 
 
            var tabItems = new TabItemCollection 
            { 
                new SfTabItem() 
                { 
                    Title = "Calls", 
                    Content = tabItem1Controller.View 
                }, 
                new SfTabItem() 
                { 
                    Title = "Favorites", 
                    Content = tabItem2Controller.View 
                } 
            }; 
 
            tabView.Items = tabItems; 
        } 



BG Bardi Golriz February 11, 2020 09:14 PM UTC

Smart! Thanks for the workaround :) I'll give it a try, and if I run into any issues with it, I'll let you know.


DV Divya Venkatesan Syncfusion Team February 12, 2020 06:15 AM UTC

Hi Bardi, 
 
Thanks for the update, we wait to hear from you. 
 
Regards,    
Divya Venkatesan     


Loader.
Live Chat Icon For mobile
Up arrow icon