I'm having a bit of trouble creating an application with multiple views and viewcontrollers where the views switch at the push of a button without an animation. Does anyone know how to do this or know of any easy to use tutorials that will help me do it?
Ok so create a new View-Based application (i will call it Clock). then create a UIViewController subclass. name this SecondViewController. Now goto your ClockViewController.h
and put
Code:
#import "SecondViewController.h"
Now we will create an IBOulet, put this under the @interface
Now lets move onto the SecondViewController.h
all we have to do is put an IBAction for returning to the First View
so right above the @end line put
Code:
Code:
-(IBAction)goBackToFirst;
OK now go to SecondViewContoller.m we have to define the IBAction so put
Code:
Thanks for redirecting me to your tutorial. However, this is great for a View-Based App. but what about in a Window Based App. Do you have to include something in the delegate? I'm still stuck. I used your tut, and it builds fine. However, once in simulator, if I click on my toolbar button to go to the page where the button is located that switches to another view, it crashes. Any help is appreciated.
I think you'll get a 1000 times better response by posting some code on this forum.
Code:
Like this!
Put your text in here, select it and then click the # sign in the editor window to wrap the CODE tags around it.
Cheers
Quote:
Originally Posted by kiambogo
Hey,
Thanks for redirecting me to your tutorial. However, this is great for a View-Based App. but what about in a Window Based App. Do you have to include something in the delegate? I'm still stuck. I used your tut, and it builds fine. However, once in simulator, if I click on my toolbar button to go to the page where the button is located that switches to another view, it crashes. Any help is appreciated.
Thanks,
kiambogo
__________________
"The attraction of knowledge would be small if one did not have to overcome so much shame on the way" - iNietzsche iPhone App
I don't have any code in my delegate files for the button or switch. With this current code, I can load my app, but if press a button (toolbar) to go to AlgebraView, it crashes. However, if i open AlgebraView.xib, and then select the button and make it NOT the LogarithmsButton, then it loads fine, but pressing the button does nothing.
Many questions don't get answered here, but usually it helps to have code samples.
Are you getting any errors or warnings when you try to build?
I will put some suggestions in Red. I'm a newbie, too so can't say if it will work. If you want to post your project file / PM me with it, I can probably better help if these suggestions don't work...
This is just for the AlgebraViewController header and implementation files, let me know if that helps at all, if not I will look at the LogarithmsViewController, too. Also, put some simple NSLog's in so you can see what event it is crashing on (check the debugging Console to see your messages.... I put these in blue for you to try.
If you're still crashing, copy and paste your console output here so I can better see where it is crashing.
Quote:
Originally Posted by kiambogo
Okay, thanks. I am new so, again, I am not completely sure how things work around here.
So again, I have AlgebraView and I want to press a button and make it go to LogarithmsView.
I don't have any code in my delegate files for the button or switch. With this current code, I can load my app, but if press a button (toolbar) to go to AlgebraView, it crashes. However, if i open AlgebraView.xib, and then select the button and make it NOT the LogarithmsButton, then it loads fine, but pressing the button does nothing.
Thanks,
kiambogo
__________________
"The attraction of knowledge would be small if one did not have to overcome so much shame on the way" - iNietzsche iPhone App
Well, I have included what you suggested. It did not work. Included is a copy of the console when I run the app. You will notice that it says "Unknown class SwitchViewController in Interface Builder file." I think that this is the problem, but you are the expert to decide that, not me
Console:
Code:
kill
quit
The Debugger has exited with status 0.
[Session started at 2009-08-20 21:08:59 -0400.]
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 245.
2009-08-20 21:09:02.580 Math Tools[245:20b] Unknown class SwitchViewController in Interface Builder file.
2009-08-20 21:11:44.972 Math Tools[245:20b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0xd1af10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key logarithmsButton.'
2009-08-20 21:11:44.973 Math Tools[245:20b] Stack: (
807902715,
2417475131,
808061681,
810717848,
810716389,
816538544,
807805711,
816533170,
816541363,
815230552,
815224116,
815223834,
815274694,
815269866,
815277278,
815276638,
814709201,
816561977,
814709201,
815110321,
815119058,
815110248,
814709201,
815110321,
815119058,
815114270,
814813151,
814722763,
814748641,
839148405,
807687520,
807683624,
839142449,
839142646,
814752238,
9316,
9170
)
(gdb)
I put it in "code" format. I think that this is just a stupid mistake that I have made, but if you could help me at all, that would be appreciated.
I'll PM you my email address, you can send me your project if you like
(make a copy of your project folder, delete everything in the Build folder, then turn it into a zip to make it really small file size)
Quote:
Originally Posted by kiambogo
Hey,
Well, I have included what you suggested. It did not work. Included is a copy of the console when I run the app. You will notice that it says "Unknown class SwitchViewController in Interface Builder file." I think that this is the problem, but you are the expert to decide that, not me
Console:
Code:
kill
quit
The Debugger has exited with status 0.
[Session started at 2009-08-20 21:08:59 -0400.]
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 245.
2009-08-20 21:09:02.580 Math Tools[245:20b] Unknown class SwitchViewController in Interface Builder file.
2009-08-20 21:11:44.972 Math Tools[245:20b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0xd1af10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key logarithmsButton.'
2009-08-20 21:11:44.973 Math Tools[245:20b] Stack: (
807902715,
2417475131,
808061681,
810717848,
810716389,
816538544,
807805711,
816533170,
816541363,
815230552,
815224116,
815223834,
815274694,
815269866,
815277278,
815276638,
814709201,
816561977,
814709201,
815110321,
815119058,
815110248,
814709201,
815110321,
815119058,
815114270,
814813151,
814722763,
814748641,
839148405,
807687520,
807683624,
839142449,
839142646,
814752238,
9316,
9170
)
(gdb)
I put it in "code" format. I think that this is just a stupid mistake that I have made, but if you could help me at all, that would be appreciated.
Thanks,
kiambogo
__________________
"The attraction of knowledge would be small if one did not have to overcome so much shame on the way" - iNietzsche iPhone App
Okay, I solved my this problem. For some reason my AlgebraViewController was set to SwitchViewController. Thanks for the tip about console, I never knew about it, but it's great! So now the page loads fine, but the problem is, that when I push the button, LogarithmsView still does not load. Here is the console.
Code:
[Session started at 2009-08-20 21:27:05 -0400.]
2009-08-20 21:27:10.336 Math Tools[564:20b] View Did Load Called
2009-08-20 21:27:13.741 Math Tools[564:20b] goToLogarithmsView Entered
2009-08-20 21:27:13.743 Math Tools[564:20b] Application tried to present a nil modal view controller on target <AlgebraViewController: 0xd18d20>.
2009-08-20 21:27:13.744 Math Tools[564:20b] goToLogarithmsView Leaving
2009-08-20 21:27:28.821 Math Tools[564:20b] goToLogarithmsView Entered
2009-08-20 21:27:28.822 Math Tools[564:20b] Application tried to present a nil modal view controller on target <AlgebraViewController: 0xd18d20>.
2009-08-20 21:27:28.824 Math Tools[564:20b] goToLogarithmsView Leaving
I think there is a problem with the code of the transition, but I'm not sure. Thanks so much for everything so far...I would be lost without you!
Cool. Logging stuff will help solve most all of your problems. Try to always implement the "Entering" and "Leaving" logs throughout all of your functions when you get stuck. It will make the program a bit heavy, so remove them / comment them out when you dont need them (my personal iPhone dev mentor blogs about them here:
The error you have now is very likely due to a broken connection in IB. Check all your connections are pointing to the right places.
I'll need to see a project file to help you any more with that error as I'm not so fluent with Xcode yet (only a couple of months experience yet)
Quote:
Originally Posted by kiambogo
Hey,
Okay, I solved my this problem. For some reason my AlgebraViewController was set to SwitchViewController. Thanks for the tip about console, I never knew about it, but it's great! So now the page loads fine, but the problem is, that when I push the button, LogarithmsView still does not load. Here is the console.
Code:
[Session started at 2009-08-20 21:27:05 -0400.]
2009-08-20 21:27:10.336 Math Tools[564:20b] View Did Load Called
2009-08-20 21:27:13.741 Math Tools[564:20b] goToLogarithmsView Entered
2009-08-20 21:27:13.743 Math Tools[564:20b] Application tried to present a nil modal view controller on target <AlgebraViewController: 0xd18d20>.
2009-08-20 21:27:13.744 Math Tools[564:20b] goToLogarithmsView Leaving
2009-08-20 21:27:28.821 Math Tools[564:20b] goToLogarithmsView Entered
2009-08-20 21:27:28.822 Math Tools[564:20b] Application tried to present a nil modal view controller on target <AlgebraViewController: 0xd18d20>.
2009-08-20 21:27:28.824 Math Tools[564:20b] goToLogarithmsView Leaving
I think there is a problem with the code of the transition, but I'm not sure. Thanks so much for everything so far...I would be lost without you!
Thanks,
kiambogo
__________________
"The attraction of knowledge would be small if one did not have to overcome so much shame on the way" - iNietzsche iPhone App
Thanks for the fast responses, I really appreciate that. Is it alright if I send you the project file? And would you just need the .project file or whatever it is called? And where do I send it to. I'm a little hesitant to post it here as I hope to publish this to the App Store sometime in the far future.
I'll PM you my email address, you can send me your project if you like
(make a copy of your project folder, delete everything in the Build folder, then turn it into a zip to make it really small file size)
I'll need to see the whole folder, but the contents of the build folder can and should be deleted as they store sometimes a lot of cache data which isn't needed when running the app somewhere else.
ie, my current app is like 40kb when I remove the build folder's contents, if I don't, it's about 2MB for a simple app!
Quote:
Originally Posted by kiambogo
Hey,
Thanks for the fast responses, I really appreciate that. Is it alright if I send you the project file? And would you just need the .project file or whatever it is called? And where do I send it to. I'm a little hesitant to post it here as I hope to publish this to the App Store sometime in the far future.
Thanks,
kiambogo
__________________
"The attraction of knowledge would be small if one did not have to overcome so much shame on the way" - iNietzsche iPhone App
Were either of you able to find out why the SecondViewController (LogarithmsView) was not loading when the button was pressed?
I seem to be running into the same issue that here seems to be some disconnect in that the second view is not loading when the button is pressed. The application does not crash, it just does not load at all like its not connected properly in IB, however my connections appear to be correct.
I went through and verified the code listed in MaXiMuM post at the beginning of the thread is the same as what I have in my project.
Were either of you able to find out why the SecondViewController (LogarithmsView) was not loading when the button was pressed?
I seem to be running into the same issue that here seems to be some disconnect in that the second view is not loading when the button is pressed. The application does not crash, it just does not load at all like its not connected properly in IB, however my connections appear to be correct.
I went through and verified the code listed in MaXiMuM post at the beginning of the thread is the same as what I have in my project.
Any suggestions?
Thanks!
Hey,
First of all, are you running a Window based app or a View based app? I switched to a View based and had no problems, I am not sure what to do about a Window based. My code for the transition between the views is here:
#import "SecondViewController.h"
@implementation SecondViewController
-(IBAction)goBackToFirst{
NSLog(@"Entering go back to first");
[self dismissModalViewControllerAnimated:NO];
}
- (void)viewDidLoad {
NSLog(@"Entering second view did load");
[super viewDidLoad];
}
I get this in the log, and nothing changes on the screen.
Code:
2009-12-11 14:12:13.271 Clock[68071:20b] Entering first view did load
2009-12-11 14:12:20.959 Clock[68071:20b] Entering go to second
2009-12-11 14:12:20.960 Clock[68071:20b] Application tried to present a nil modal view controller on target <ClockViewController: 0x3d21280>.
Hi, I'm having the same problem, but I can't figure out how to connect the secondView outlet to the SecondViewController in interface builder. How did you do it?