Multiview problem..

Discussion in 'iOS Programming' started by bytezone, May 17, 2009.

  1. bytezone macrumors member

    Joined:
    Apr 20, 2009
    #1
    I tried doing the multive example from book "Begining Iphone Development"(chapter 6) by Dave Mark.

    When I run the application all I get is iphone simulator with blank(black) screen. I have colored the view..but still does not show up. I checked for any error in console application and found none. When run the project, I do get the message in the status bar as "MultiviewProject launched". My project name for this example is Miltiview.Project. I confirmed the steps with book couple of times, but no use yet. Has anyone being through similar problem..?? What could be reason for getting a black screen..?? I can post the whole project in compressed form if this forum has any option...!!! I am frustrated with this problem after having checked the code and steps many times with book.


    Thanks in advance for help...
     
  2. CocoaPuffs macrumors 68010

    Joined:
    Aug 23, 2008
    #2
    Copy and paste the codes, and you probably missed linking the nibs to view.
     
  3. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #3
    Hey Thanks for the help. I was missing the connection from file's owner to App delegate in MainWindow.xib(is this told in the book..??). However I am now able to get to display the view of MainWindow.xib(this gets created when we chose window based application).

    But I am unable to get the other nib file open on above view. Here is the code which is in swithViewController. Instead of BlueViewController I am using MainViewController. I also have nib file MainView.xib created. I did all the changes to MainView.xib as explained in page 130 to make sure that class which will load the MainView.xib file is MainViewController.When I run the project, I get to see what is in View of MainWindow.xib only...!!!! Any suggestions...???

    .
    Code:
    - (void)viewDidLoad {
    
    	MainViewController *mainController = [[MainViewController alloc]  initWithNibName:@"MainView"  bundle:nil];
    	self.mainViewController = mainController;
    	[self.view insertSubview:mainController.view atIndex:0];
    	[mainController release];
    	NSLog(@"Reached here too.....!!!");
    
    
    }
    Thanks in advance....
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    What does your switchViews method look like? The code from the book contains a few typos.
     
  5. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #5
    I have not yet implemented swithView method. I would like to go in steps so that I could catch any problem(like this) before it gets too complicated to find.

    I am now trying to find when the project is executed ..does it open the MainView.xib which needs to be the first View to display.
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    So, what is BlueView in the book you are calling MainView? Is that right?

    Also, switchViews is added on page 127. But you haven't implemented it yet?

    I guess I'm a little confused. What are you expecting to happen and what are you seeing instead?
     
  7. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #7
    You are right..BlueView in Book is MultiView in my project. So far I have implemented ViewDidLoad in SwitchViewController which assignes the View of MultiView.xib.

    Switch view is not yet impelemnted as I don't like to see the switch in action now. According what I have implemented, I should be seeing the view of MultiView.xib as it should get loaded from viewDidLoad of SwitchViewController. But I see view of MainWindow.xib..... !!!

    Why is it so..???
     
  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    Wait. MultiView or MainView. Which is it?
     
  9. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
  10. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #10
    And you reconnected the MainViewController's view outlet to the view of the MainView nib, as explained at the bottom of page 130?
     
  11. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #11
    Here is what I observed..thought it might help you in figuring out the problem...

    Looks like the view of MainWindow.xib is not getting replaced by the view of MainView.xib. When I run the project I get to see the view of MainWindow.xib. I changed the name for MainView.xib to some random name in code..
    Code:
    MainViewController *mainController = [[MainViewController alloc]  initWithNibName :@"MainView"  bundle:nil];
    
    To
    Code:
    MainViewController *mainController = [[MainViewController alloc]  initWithNibName :@"MainXXXX"  bundle:nil];
    
    When I executed the project I again saw View of MainWindow.xib..this means ViewDidLoad of SwitchViewController is not getting called..means …MainWindow.xib is not set to receive objects from SwitchViewController. But I made all the required changes to MainWindow.xib as given in page 124. I accept the error is in my part..but I am unable to trace it.

    Help is much appreciated…
     
  12. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #12
    Yes I have connected...!!!
     
  13. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #13
    Are you sure about that? You've put an NSLog or breakpoint in it to verify?

    P.S. If you're able, attach a zip of your project to your post so we can examine it as well.
     
  14. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #14
    dejo,

    Greatly apprecite for trying to help me out. I am unable to attach the file as the size of zip file is more than max allowed in forum.

    Can you send me a private message with your email adress.I will mail you..???
     
  15. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #15
    Seriously? The zip file would be bigger than 1.14 MB? Wow, what do you have in this project? The zip file for the project for Chapter 6 weighs in at 16 KB.
     
  16. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #16
    I cross checked again..the file size is 1.4 mb...!!!!
     
  17. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #17
    So, I take it you added some stuff other than what is covered in the Chapter 6 code. Cuz 16 KB vs. 1.4 MB is a huge difference.
     
  18. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #18
    Yup its a too much difference.

    I compared chp 6 and my file..I have zipped build file also.

    I am totaly new to mac..started using from past 1-2 weeks and was not sure what all needs to be zipped. Thanks for informing me...!!!

     
  19. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #19
    Delete the build folder from the project before zipping up the project folder.
     
  20. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #20
    Thanks for suggestions...!!!!

    Dejo...I emailed the file to you...any luck on it ...!!!
     
  21. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #21
    Still investigating...

    I did notice you had:
    Code:
    MainViewController *mainController = [[MainViewController alloc]  initWithNibName:@"MaiVew"  bundle:nil];
    
    where you want:
    Code:
    MainViewController *mainController = [[MainViewController alloc]  initWithNibName:@"MainView"  bundle:nil];
    
    But, I fixed that and it didn't help... darn...

    Hopefully just another typo elsewhere...
     
  22. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #22
    I had done that myself to check if it gives any error. That's when I said it is not reaching ViewDidLoad. But I forgot to edit it before zipping it.

    Looking forward to your response....
     
  23. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #23
    Got It!

    If you're going to override the default loadView for a viewController, you need to make sure you still call the loadView for it's superclass.

    So, instead of this in your MainViewController.m:
    Code:
    - (void)loadView {
    	NSLog(@"Inside Main View");
    }
    
    you should be doing:
    Code:
    - (void)loadView {
    	[super loadView];
    	NSLog(@"Inside Main View");
    }
    
    With this change and the one from my previous post, things should work as expected.
     
  24. bytezone thread starter macrumors member

    Joined:
    Apr 20, 2009
    #24
    Dejo,

    THANKS a ton..!!! It worked.

    I missed this as this what not mentioned in chapter 6 source code and also in the book...!!!!
     
  25. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #25
    No, because the loadView method is never overridden in those cases.
     

Share This Page