I created a button in my cover.h file for my first view
#import <UIKit/UIKit.h>
@interface cover : UIViewController
{
IBOutlet UIButton *Enter;
}
@property (nonatomic, retain) UIButton *Enter;
-(IBAction)buttonpressed:(id)sender;
@end
and connected it with the actual button in the inteface builder by choosing File’s Owner in the tiny box that gives you the choice of File’s Owner, First Responder, and View
Then I went to cover.m file and added the following code
-(IBAction)buttonpressed:(id)sender
{
[[NSBundle mainBundle] loadNibNamed:@"nextView" owner:self options:nil];
NSLog(@"pressed");
}
SO when I go to the nextView.xib and modify nextView.m and nextView.h and access its buttons and do the same thing I did for cover.xib cover.m and cover.h , it doesn’t work properly.
What happens is that when I click the enter button in the cover view it shuts down the app. This does not happen until I connected the button to function and outlet (Meaning when it was just switching views and the second view wasn’t doing anything it would work)
Thank you for any help you can give. Sorry if I haven’t given enough information, kinda new at this, but as find out more info I should have had, I will add it.
Thank you
Edit 1 :
I did not notice anywhere where it said there was an error or anything like that. It built correctly
CoverViewController. This makes it more obvious, when reading your code, what we’re looking at.What is your intent here? To show nib after nib of content?
Is the “files owner” of every nib a
CoverViewController?What you have actually done is (catastrophically) reloaded the views for the existing controller. This will not end well.
What you want to do is create another instance of the same class:
If you’re not using a nav controller, you probably want to be.
Read up on the View Controller Programming Guide.