How to use UITabarViewController in Xcode - OBjectiveC?

my code:

UIView *screen=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
screen.backgroundColor=[UIColor grayColor];
UIView *screen2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
screen.backgroundColor=[UIColor redColor];
screen2.backgroundColor=[UIColor greenColor];

UITabBarController *tab=[[UITabBarController alloc]init];
[tab setViewControllers:[NSArray arrayWithObjects:screen,screen2, nil]];

self.view=tab.view;

but when I run it has Exception at: [[tab setViewControllers:[NSArray arrayWithObjects:screen,screen2, nil]];

Can anybode tell me why?, i'm beginner Thanks

Answers


You are adding UIView to your tabbar view controllers. You should add view controllers like UIViewControllers. this shows how you can add uitabbarcontroller programatically link


a UITabBarController viewControllers property is an array of UIViewController's not UIViews, you need to initialise the array with view controllers instead of views

The view controller programming guide is a good place to start reading about this


Need Your Help

SELECT TableName.Col1 VS SELECT Col1

mysql select

This might be a weird question but didnt know how to research on it. When doing the following query:

Setting asp.net text box value using jquery with ajaxcontroltoolkit watermark

jquery asp.net textbox ajaxcontroltoolkit watermark

I am using asp.net textboxes with ajaxcontroltoolkit watermark control. There is a list box with entries that can be edited using the text boxes. On selection change of the list box I need to set the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.