Shivbaba's son
Shivbaba's son

Reputation: 1369

Is it Possible to have two view Controller's IBOutlet in one .h file? How to move to previous to previous view?

I am using XCode 4.

In My applicaion I have Files

In every view I have same functionality.

Pressing the Button and Load another view By presentModelViewController..

Problem I am Facing is I can not Declare Two outlets in One header file As If I want to move to the Back Page.?

#import <UIKit/UIKit.h>

#import "ThirdViewController.h"

#import "FirstViewController.h"

@interface SecondViewController : UIViewController {
    UIButton *button1;
}

@property (nonatomic,retain) IBOutlet ThirdViewController *thirdVC;
@property (nonatomic,retain)  IBOutlet FirstViewController *firstVC;
//Error at this line above 
@property (nonatomic,retain) IBOutlet UIButton *button1;

@end

Is it a good practice to alloc and init the new controller or I just have to take a view controller in XIB file and then just create Outleyts??? Yes you are right definbately, I have tried it is working...but why I am taking View Controller because I just can jump to previous to previous view ? What is wrong If I take an IBOutlet.???

So, What if I want to move previous to previous view I need to write two times [self dismisviewContrlloer animated:YES];

[self dismisviewContrlloer animated:YES]; ????

Upvotes: 0

Views: 235

Answers (3)

Shivbaba&#39;s son
Shivbaba&#39;s son

Reputation: 1369

[self.parentViewContrtoller.parentViewController dismissModalViewControllerAnimated:YES];

By this method I can Jump Back to the previous to previous move.

Upvotes: 0

Praveen S
Praveen S

Reputation: 10393

Why would you want to have 3 outlets? Just have properties for the viewcontroller. Alloc and init and present the views of the same controller class.

So basically you will have a xib file for a viewcontroller and you will need to create as many instances of that depending on your requirement. Looking at the code i think it needs lot of redesign. You present and dismiss these views accordingly.

Upvotes: 1

Akshay
Akshay

Reputation: 5765

Actually, all you need to do is [self dismissModalViewControllerAnimated:YES]; If the 3rd view is visible, the 2nd one will automatically become visible. Similarly the 1st from the 2nd. You don't really need to store references to adjacent view controllers in each view controller.

HTH,

Akshay

Upvotes: 1

Related Questions