开发者

IPHONE - Use multiple views

I have to make an application with six views, which can be accessed to by bar button items on a toolbar.

I'm really new at this. I have a view controller and a XIB file for each view, with six functions (goToView1, goToView2, ..., goToView6).

Here is an example :

SecondViewController *secondview;

-(IBAction)goToView2 {
    secondview = [[SecondViewController alloc] 
                 initWithNibName:@"SecondViewController" bundle:nil];
    [self.view addSubview:secondview.view];
}

But as you can see, if I want to go from view3 to view2, I'm not deleting the view3 from the stack : I'm just adding the view2 over it. So here's my problem, how do I "delete" my view before using addSubView ? I tried with removeFromSuperView, but I think I'm not using it right.

Thanks for helping开发者_如何转开发, as I said I'm really new and I am aware it can be a stupid question :/


It sounds very much like you want to use a UITabBarController, as this will provide the toolbar (with icons), etc. and will automatically handle displaying the appropriate view controller when a specific toolbar icon is selected.

However, I'd really recommend first reading the View Controller Programming Guide for iOS document, as it provides a good overview of the various UIKit controllers, etc. and how they should be used. If you take the time to read and understand this now, it'll serve you well in the future.


Take a look at UITabBar. I think using a tab bar might be better suited for what you want to do, than a toolbar.

UITabBar Class Reference


to remove the fisrt view you should use something like this.

   [fisrtView removefromSuperview];

put in where you want to remove view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜