Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iLoveDeveloping

Suspended
Original poster
Sep 24, 2009
596
2,366
Ireland
Hey,


I am doing a navigation type app, and on the MainWindow.xib is the tab bar that i added a 'back' button to.. Now i need to code that window to make the back button work..

In the classes section i only have

-RootViewController and AppDelegate.

So my question is, where can i put the code so that it can be linked to the mainwindow.xib. Because if i put the 'back button' code in the rootviewcontroller.h/m the link shows up on RootViewController.Xib, if i put it in AppDelegate.h/m, it doesn't show up anywhere...

So where do i put it to show up in IB for MainWindow.Xib?

Thanks... (i realize this might be a dumb question...)
 
If you want to add an action to a part of a view, the view must be connected to the class file. To change which class file the view is connected to, click the far right tab in inspector once you've selected the view.
Thanks... (i realize this might be a dumb question...)
There is no such thing as a dumb question. I'm happy to help all developers if I can, whether they are beginners or experts.
 
If you want to add an action to a part of a view, the view must be connected to the class file. To change which class file the view is connected to, click the far right tab in inspector once you've selected the view.

sorry i am not following you? so say i have the code

Code:
 - (IBAction)goback{
	[self dismissModalViewControllerAnimated:YES];	
}

Where do i put this code so that i can connect it to the button i put into the MainWindow.Xib in Interface Builder?
 
sorry i am not following you? so say i have the code

Code:
 - (IBAction)goback{
	[self dismissModalViewControllerAnimated:YES];	
}

Where do i put this code so that i can connect it to the button i put into the MainWindow.Xib in Interface Builder?

Open MainWindow.Xib. Click on the view with the button. On the top, click "File>Write Class Files". In these class files that you've just written, put action. Note: There is a comment in the .h file that explains a direction you need to do before you can run it.
 
Note: There is a comment in the .h file that explains a direction you need to do before you can run it.


No there is not.... This is all i got....
Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface RootViewController : UITableViewController {
    IBOutlet id delegate;
}

- (IBAction)goback;

@end
 
There might be, but not in mine.... There is no back button anywhere, i had to create my own..
It won't appear unless you have more than one viewController on the nav stack. But you have a modal view, is that right? And it's defined via MainWindow.xib? Maybe give us more details of your view logic (what appears first, how you move to other views, etc.) so we can better understand what you are trying to achieve and why what you have isn't working.
 
It won't appear unless you have more than one viewController on the nav stack. But you have a modal view, is that right? And it's defined via MainWindow.xib? Maybe give us more details of your view logic (what appears first, how you move to other views, etc.) so we can better understand what you are trying to achieve and why what you have isn't working.

Oh i understand what you mean now, yes there is a Default back button 'from the SECOND view on', but i want one on the FIRST view, i have a viewcontroller for the first screen when the App launches, then you press a button and it goes to the Nav screen, but i want to get back from the first nav screen to the first View when the App starts... I am trying to put a back button into the FIRST Nav screen...
 
i have a viewcontroller for the first screen when the App launches, then you press a button and it goes to the Nav screen...
Hmm, seems to me you have played around with the basic structure that is provided with the Navigation-Based Application template. Normally, with that template, you would not even touch MainWindow.xib. If I was doing this, I would start with the basic template code, add a new UIViewController (w/ view) to contain your "first" screen and present that modally upon application launch. Within that new UIViewController add an IBAction for a Back button which simply dismisses the modal view controller so you end up back at your nav-controlled table view.
 
Hmm, seems to me you have played around with the basic structure that is provided with the Navigation-Based Application template. Normally, with that template, you would not even touch MainWindow.xib. If I was doing this, I would start with the basic template code, add a new UIViewController (w/ view) to contain your "first" screen and present that modally upon application launch. Within that new UIViewController add an IBAction for a Back button which simply dismisses the modal view controller so you end up back at your nav-controlled table view.

No starting it again is not an option, I have put to much work into it, I just need to put 1 button on a view, I'm not redoing my whole app in a new way just for that! I just need to recreate the viewcontroller from the nav screen! And I need a button to do that... How is that done?
 
No starting it again is not an option, I have put to much work into it, I just need to put 1 button on a view, I'm not redoing my whole app in a new way just for that! I just need to recreate the viewcontroller from the nav screen! And I need a button to do that... How is that done?
Have you put that much work into MainWindow.xib? Create a new UIViewController w/ view, move MainWindow stuff to new view, present modally, dismiss on button press, done. (My apologies to Chef Ramsay).
 
Have you put that much work into MainWindow.xib? Create a new UIViewController w/ view, move MainWindow stuff to new view, present modally, dismiss on button press, done. (My apologies to Chef Ramsay).


No, i want to dismiss the Nav screen with a button, not the View! The view is perfect and nothing wrong with it!!!

I can get from the view, to the Nav screen, all i need is how to get back from the Nav screen to the view...??
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.