سؤال

I found a UIPagecontrol example while googling and this works perfectly when i try to create this as a completely new project. Now i want to add this to my code

@interface filename2 ()

@end

@implementation filename2

@synthesize View1;
@synthesize View2;
@synthesize View3;



- (void)viewDidLoad
{
// Do any additional setup after loading the view, typically from a nib.
[super viewDidLoad];

[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View1"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View2"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View3"]];




}


@end

But the problem I'm facing is that I'm not using storyboard I'm using ViewController.xib so how can i change this code to use it with my application?

هل كانت مفيدة؟

المحلول

Use initWithNibName: Method for using xibs.

Example

ViewController *v1=[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[self addChildViewController: v1]];

نصائح أخرى

Replace [self.storyboard instantiateViewControllerWithIdentifier:@"View1"] with object of your ViewController.

Have you tried using

NSArray* views = [[NSBundle mainBundle] loadNibNamed: owner: options:]

Xib is a Nib in xml format.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top