![](/img/trans.png)
[英]How to link a separate storyboard to each particular tab in uitabbarcontroller?
[英]Adding a webview for each tab in UITabBarController?
如何為 UIViewController 中的每個選項卡添加 Web 視圖?
public class TabController: UITabBarController
{
UIViewController tab1, tab2, tab3, tab4, tab5, tab6, tab7;
public TabController()
{
tab1 = new UIViewController();
tab1.Title = "Test";
tab1.View.BackgroundColor = UIColor.Orange;
tab2 = new UIViewController();
tab2.Title = "Test2";
tab2.View.BackgroundColor = UIColor.Orange;
tab3 = new UIViewController();
tab3.Title = "Test3";
tab3.View.BackgroundColor = UIColor.Red;
tab4 = new UIViewController();
tab4.Title = "Test4";
tab4.View.BackgroundColor = UIColor.Red;
tab5 = new UIViewController();
tab5.Title = "Test5";
tab5.View.BackgroundColor = UIColor.Red;
tab6 = new UIViewController();
tab6.Title = "Test6";
tab6.View.BackgroundColor = UIColor.Red;
tab7 = new UIViewController();
tab7.Title = "Test7";
tab7.View.BackgroundColor = UIColor.Red;
var UIViewController = new UIViewController[] {
tab1, tab2, tab3, tab4, tab5, tab6, tab7
};
tab1.TabBarItem = new UITabBarItem(UITabBarSystemItem.Favorites, 0);
ViewControllers = UIViewController;
}
}
所以對於每個標簽,而不是“tab1.View.BackgroundColor = UIColor.Orange;”,它應該是:Webview + Title + Link 以便每個標簽都有不同的頁面?
最簡單的方法是使用情節提要並將視圖控制器類分配給您的選項卡。 但是,如果您想以編程方式執行此操作,我想您需要執行以下操作:
tab7 = new UIViewController();
tab7.Title = "Test7";
tab7.View.BackgroundColor = UIColor.Red;
//Create a webview
UIWebView webView = new UIWebView(View.Bounds); //Takes size as a constructor parameter
//Set it's navigation location
webView.Navigate(new URI("www.whatever.co.uk"));
//Add the webview to the subviews of your UIViewController
tab7.View.AddSubview(webView);
您將為每個選項卡執行此操作。
另外值得一提的是,蘋果關於向其商店提交應用程序的指南確實傾向於不贊成只是網站表示的應用程序,因此值得牢記這一點。 該應用程序必須能夠比蘋果的網絡瀏覽器做更多的事情。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.