tzr15 Posted December 17, 2008 Share Posted December 17, 2008 I am a rookie and I need help. I can easily create new apps with one view in one window. And I can populate that view with whatever I want and tie the features (buttons, text fields , etc) to IBActions in my class files. What I can not do, is use multiple views in one nib file or multiple nib files. Here is what I am trying to do. (My actual app is more involved, but if I can get a template going that does the following, I can can expand it from there: Start App First window/view appears and has one UIButton. I press that button and the the next view now appears. Done It should be simple, but it isnt. I can not use navigation bars or tab bars. I need to use a UIButton. I know that the UIButton needs to connect to an IBAction that has the code to remove the current view and add the new subview. But here are my questions... Do I start with Window based template or view based template? View based says its for one view, I will have multiple, so I am guessing I want window based. If I go with window based, do I need to create any new classes, like a viewcontroller? If I tr using addsubview or removefromview commands in the main.m, it doesnt recognize them. If I use a new viewcontroller.m class that is a sub o UIViewController then the commands are ok. In Interface Builder do I also create a UIViewController? What do I link my File's Owner to? What links do I need? I can get everything to compile fine. Once I add more than one view to my nib, it starts crashing. I can get it all connected and no crashes, but then when the app starts, it never loads the first view. So could someone please help me template out a starter app that does this and tell me what to do in IB to tie it all in, or maybe Ican skip IB and go progrmatically? Start App First window/view appears and has one UIButton. I press that button and the the next view now appears. Done Thanks, Rob Link to comment Share on other sites More sharing options...
Poco Posted December 17, 2008 Share Posted December 17, 2008 Are you programming for iPhone/iPod? If you are you could use the TabBar controller. With that you can specify tabs to import the view from another nib. http://www.iphonesdkarticles.com/2008/07/t...r-tutorial.html iPoco Link to comment Share on other sites More sharing options...
tzr15 Posted December 17, 2008 Author Share Posted December 17, 2008 Sorry. i forgot to state that this is for the iPhone. I can not use the tab bar or the nav bar. I have to use a custom UIButton. There will actually be several buttons. But if I can get it figured out for one, I can add the others easily. This is the problem I am having. There is plenty of documentation to use the built in controls, tab bar, nav bar, table view, etc. I need to use a custom UIButton. Cant find any docs on that. Thanks, Rob Link to comment Share on other sites More sharing options...
Poco Posted December 17, 2008 Share Posted December 17, 2008 Why would you have to use UIButton? I don't know how to launch a window off the top of my head but you could make an IBOutlet and link the button click event to the IBOutlet which launches the window. iPoco Link to comment Share on other sites More sharing options...
tzr15 Posted December 18, 2008 Author Share Posted December 18, 2008 Due to the nature of my app, its a brain teaser that tracks your choices and does certian things based on your input, I have to have custom buttons with custom images in custom locations. You said, "you could make an IBOutlet and link the button click event to the IBOutlet which launches the window" I have made a button that ties to an IBAction. The problem is what code to put in that action to trigger the view change. And, does the IBAction go in the mainappdelegate class or in a navigationcontroller class or a uiview controller class and then how do you connect it all in IB? No one has been able to figure this out on many message boards. Every one just says, "use the standard nav buttons" or "just tie the button to the action", but it doesnt work. Could someone please try it themselves and you will see that there is much more to it. Link to comment Share on other sites More sharing options...
Bob Ronson Posted December 18, 2008 Share Posted December 18, 2008 Look at the template for the Utility Application in Xcode. It uses an info button to toggle the view, which is a UIButton. The RootViewController in this case handles the UIButton outlet. You can use this method in your app. Link to comment Share on other sites More sharing options...
tzr15 Posted December 18, 2008 Author Share Posted December 18, 2008 You are a life saver!! I added my graphics to the nib files for the 2 views and added my own UIButton that I connected to thebuilt in toggleView IBAction and it works!!!! I will need to remove the infoButton and the nav bar but that should be easy. I also want the animation between views to be a zoom in from center , like when you launch an app. And I will need to add another button and 3rd view, but I think I can do that. But other than that, this does exactly what I want. I can get there from here!! Thank you so much!!!! Rob Oh man oh man!!!!!!!!!!!! I just got the base of my app complete. It took me less than an hour. I now have my custom graphics on view 1. When I push the button it flips to view 2. It has a button. When I push it, it flips to view 3 which has my custom image. (And I got rid of the navbar and infobutton) Now all I have to do is try to change the animation style and add my other buttons. I will easily have this app ready for release this weekend!!!!!! I am writing your name down Bob and I swear, if this app makes money, I am paying you a commision!! Thank you again!!! Link to comment Share on other sites More sharing options...
Recommended Posts