IOS - NIB view used in storyboards (for design logic and animation)

I have an iOS 5 project almost completed, but there is one view missing everywhere, which is the same. This is an alternative to the standard navigation navigator, you can "return" to the navigation hierarchy using a swipe and animate well.

Well, because it is difficult to execute the mock by code, I created an empty IB document (HeaderView.xib), where I have a view containing subview, etc. I had animation code, so I just created a subclass of UIView ("HRAnimationView") (and wrote its name in the "Custom class" field of xib inspectors, also connected the routines to the outputs) using the method:

- (void)loadAnimation {…}

and the second (this is the delegate method for the finished animation):

- (void)animationDidStop:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context {}

... that’s where all the animated things happen and calls himself over and over until it ends ...

In the storyboard, I have a subview with exactly the same dimensions (and output for it) and wanted to load the XIB (in the viewDidLoad method of the corresponding controller) using

NSArray *bundle = [[NSBundle mainBundle] loadNibNamed:@"HeaderView" owner:self options:nil];

HRAnimationView *view;

for (id object in bundle) {        
    NSLog(@"%@",object);
    if ([object isKindOfClass:[UIView class]])
        view = (HRAnimationView *)object;
}

self.headerView = view;
[self.view setNeedsDisplay];
[view loadAnimation];

BUT the title of the View is EMTPY !! (also viewing UIView * did not work, as well as the owner: self.headerView)

... The magazine just gives me:

<HRAnimationView: 0x3f1890; frame = (0 0; 240 49); autoresize = RM+BM; layer = <CALayer: 0x3f18d0>>

...

WHAT IS THE PROBLEM ?? There is also no compilation failure!

I do not understand why xib is TOTALLY useless in my case ?!

+3
source share
2 answers

SOLVE!!!

ViewController "create with xib" xib & , ViewController viewDidLoad.

viewDidLoad ViewController :

UIViewController *ctrl = [[UIViewController alloc] initwithNibNamed:@"HeaderView"];
[self.headerView addSubview:ctrl.view]

(headerView - IBOutlet , , , NICE!)

, Xib ViewController, (.. ). , , - , !

0

NSArray * bundle = [[NSBundle mainBundle] loadNibNamed: @ "HeaderView" : self options: nil];

...

[self.headerView = [bundle objectAtIndex:0]

0

All Articles