2

I have one story board project with many view controllers and i created one class named "connecter.h,connector.m " now can i connect this class to one .xib file ?

Please help me.

Naveen
  • 1,251
  • 9
  • 20
  • 38
  • - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { } return self; } – Naveen Mar 22 '13 at 10:19
  • can i use the abouve methode for loading xib??? – Naveen Mar 22 '13 at 10:19

4 Answers4

5

You can create XIB when you create connector.h and connector.m by selecting it subclass of UIViewController and click on the checkbox for: "With XIB for User Interface". If you have created already .m & .h files then you can just add a new GUI file by selecting View from the window & finally setting its Controller Custom class to connector You could have StoryBoard and XIB together in the same project. See for more help.

For presenting the view Controller you could use the following code

YourViewController *viewController=[[YourViewController alloc]initWithNibName:@"ViewControllerName" bundle:nil];

[self presentViewController:viewController animated:YES completion:nil];

In case of NavigatinController

   [self.navigationController pushViewController:viewController animated:YES];
Community
  • 1
  • 1
nsgulliver
  • 12,655
  • 23
  • 43
  • 64
  • Iam new to this storyboard can u show me some example codes?? – Naveen Mar 22 '13 at 10:23
  • I READ THAT LINKS ,YOU MEAN PUT THAT XIB FILE INSIDE SOMEWHERE IN PROJECT AND ASSIGN ITS CLASS AS CONNECTER.M IN THE IDENTITY WINDOW ??IS THAT ENOUGH?? – Naveen Mar 22 '13 at 10:24
  • Yes you can add the file separately or together with connector.h & connector.m, In the Identity Inspector select the connector as its custom class. – nsgulliver Mar 22 '13 at 10:26
  • I WANT OPEN THAT XIB WHEN I CLICK THE BUTTON IN FIRST VIEWCONTROLLER IN MY STORY BOARD? HOW CAN I DO THAT THING?HOW DO I SPECIFY THE CODE FROM THAT BUTTON? – Naveen Mar 22 '13 at 10:29
  • just declare the ViewController using `YourViewController *vieController=[[YourViewController alloc]initWithNibName:@"ViewControllerName" bundle:nil];` and presenet it using presenetViewController. – nsgulliver Mar 22 '13 at 10:33
0

Do this to bind your connector class with xib:[here i have bind ViewController class with xib]

select files owner and in custom class write your class name And connect the view with File's owner. And your Connecter class must be of type ViewController and have the method

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
Shah Paneri
  • 729
  • 7
  • 28
0

Open the story board in your editor and click on any of the view controllers. Doing this will list all the proxy objects that you have come to be used to see when you selected any xib. Following image must help you understand better.

enter image description here Now goto the Identity Inspector tab and enter you class name in the highlighted text field

Suhas
  • 1,500
  • 11
  • 15
0

Create one Xib file set the FilesOwner class as connecter.h . The while creating the instance of connector class

[[connecter alloc] initWithNibName:@"Nib_Name" bundle:nil];
Anil Varghese
  • 42,757
  • 9
  • 93
  • 110