switching views in iphone

后端 未结 3 1530
滥情空心
滥情空心 2021-01-17 04:40

i m making a client server program in which i want to switch from one view to another but i am getting an error in \"clientserverprogram view.m\" plz help

\"         


        
3条回答
  •  清歌不尽
    2021-01-17 04:45

    [self presentModalViewController: secondview animated: YES ];
    
    "" error: expected expression before 'secondview'""
    

    This line of code is responsible to present modal ViewController. In your case you only had a view. So either you create a controller for the second view like that:

    SecondViewController *secondController=[[SecondViewController  alloc] initWithNibName:@"secondView" bundle:[NSBundle mainBundle]];
     [self presentModalViewController:secondController animated: YES ];
    

    or you can load you second view from nib file using outlet and you can add it as subview to your current view controller view:

    [self.view addSubView:secondview]; 
    

    Update

    As I can see on your code SecondView is your controller not the view, but you are try to present a controller that is not initialized. I also noticed that you have an outlet for your view on SecondView, when you create a new sub class of UIViewController you can check the option that creates a .xib file as well.

    Hope that helps,

提交回复
热议问题