0

I have a storyboard with one view controller that pushes another view controller with this code:

    UIViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"adVideo"];
    [self presentViewController:viewController animated:NO completion:nil];

In the view controller being pushed, there is a UIView that I'm trying to get the frame for so that I can use it to place another object. I've connected it to a UIView IBOUTLET property in my viewcontroller class and then in viewDidAppear for that view controller I call on the frame but it comes up as empty (0,0,0,0).

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
        NSLog(@"%f %f %f %f", self.videoView.frame.origin.x, self.videoView.frame.origin.y, self.videoView.frame.size.width, self.videoView.frame.size.height);
}

What's the reason for the videoView not being loaded by that point so that the frame can be passed?

Billy Shih
  • 624
  • 6
  • 17
  • are you sure self.videoView is not nil and you didn't mix up the two view controllers by mistake? – Martin Ullrich Mar 01 '13 at 21:31
  • When I run the app, it shows the correct view controller being pushed and then on that view controller I can see the videoView. I also checked to see that the IBOUTLET was indeed attached to the storyboard correctly. – Billy Shih Mar 01 '13 at 21:49
  • can you set a breakpoint on that NSLog, get the memory address of your videoView using `po [self videoView]` and see if you can find in the output of `po [[UIWindow keyWindow] recursiveDescription]`? – Martin Ullrich Mar 01 '13 at 22:11
  • When I do this the recursiveDescription shows only items from the previous View Controller. po [self videoView] does work and exists though. – Billy Shih Mar 01 '13 at 22:32
  • You shouldn't use the word "push" to describe what you're doing -- a push is a specific transition done by navigation controllers. The controller is being "presented". If you log self, do you get your subclass? BTW, you can use NSLog(@"%@",NSStringFromCGRect(self.videoView)) to print out the frame more easily. – rdelmar Mar 01 '13 at 23:29
  • Thanks for the tips @rdelmar. What do you mean by subclass? When I log self it seems to provide the memory for the newly presented viewcontroller. – Billy Shih Mar 01 '13 at 23:55
  • But what class does it say it is? Is it your subclass or is it UIViewController? I see in you question that you are saying viewController is a UIViewController, but if it is, how can you have any custom content in it? – rdelmar Mar 02 '13 at 01:01
  • I ended up using a UIButton instead of the UIView for the same purpose and it worked. Not sure of the problem still, but thanks for your help @rdelmar – Billy Shih Mar 04 '13 at 17:41
  • The videoView is the problem, if you try it with self.view it's working. There is no any info about it, so it's rather difficult to check it, but you could do it...just for the record. – BootMaker Mar 30 '13 at 20:46

0 Answers0