PDA

View Full Version : Multiview problem..




bytezone
May 17, 2009, 10:40 PM
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...



CocoaPuffs
May 17, 2009, 10:46 PM
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...
Copy and paste the codes, and you probably missed linking the nibs to view.

bytezone
May 18, 2009, 09:19 AM
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...???

.
- (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....

dejo
May 18, 2009, 10:13 AM
What does your switchViews method look like? The code from the book contains a few typos.

bytezone
May 18, 2009, 10:18 AM
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.

dejo
May 18, 2009, 10:28 AM
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.
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?

bytezone
May 18, 2009, 10:51 AM
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..???

dejo
May 18, 2009, 11:34 AM
You are right..BlueView in Book is MultiView in my project.
Wait. MultiView or MainView. Which is it?

bytezone
May 18, 2009, 12:15 PM
Sorry its MainView...!!!!

dejo
May 18, 2009, 12:26 PM
And you reconnected the MainViewController's view outlet to the view of the MainView nib, as explained at the bottom of page 130?

bytezone
May 18, 2009, 12:28 PM
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..

MainViewController *mainController = [[MainViewController alloc] initWithNibName :@"MainView" bundle:nil];

To

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…

bytezone
May 18, 2009, 12:29 PM
Yes I have connected...!!!
And you reconnected the MainViewController's view outlet to the view of the MainView nib, as explained at the bottom of page 130?

dejo
May 18, 2009, 12:33 PM
When I executed the project I again saw View of MainWindow.xib..this means ViewDidLoad of SwitchViewController is not getting called
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.

bytezone
May 18, 2009, 12:45 PM
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..???

dejo
May 18, 2009, 12:50 PM
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.
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.

bytezone
May 18, 2009, 01:07 PM
I cross checked again..the file size is 1.4 mb...!!!!

dejo
May 18, 2009, 01:11 PM
I cross checked again..the file size is 1.4 mb...!!!!
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.

bytezone
May 18, 2009, 01:18 PM
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...!!!

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.

PhoneyDeveloper
May 18, 2009, 02:16 PM
Delete the build folder from the project before zipping up the project folder.

bytezone
May 18, 2009, 02:24 PM
Thanks for suggestions...!!!!

Dejo...I emailed the file to you...any luck on it ...!!!
Delete the build folder from the project before zipping up the project folder.

dejo
May 18, 2009, 03:23 PM
Dejo...I emailed the file to you...any luck on it ...!!!
Still investigating...

I did notice you had:
MainViewController *mainController = [[MainViewController alloc] initWithNibName:@"MaiVew" bundle:nil];

where you want:
MainViewController *mainController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];


But, I fixed that and it didn't help... darn...

Hopefully just another typo elsewhere...

bytezone
May 18, 2009, 03:31 PM
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....

dejo
May 18, 2009, 03:35 PM
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:
- (void)loadView {
NSLog(@"Inside Main View");
}


you should be doing:
- (void)loadView {
[super loadView];
NSLog(@"Inside Main View");
}


With this change and the one from my previous post, things should work as expected.

bytezone
May 18, 2009, 03:57 PM
Dejo,

THANKS a ton..!!! It worked.

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

dejo
May 18, 2009, 04:06 PM
I missed this as this what not mentioned in chapter 6 source code and also in the book...!!!!
No, because the loadView method is never overridden in those cases.

bytezone
May 18, 2009, 04:07 PM
Dejo,

I was able to find the error...
the initializer for MainViewController was commented. So controller with requested xib file was not getting created. I uncommented it and also commented the loadView....it worked...!!!

But still..greatly appreciate for your help....!!!Thanks again..!!!