0

I have static library and my custom view controller inside (f.e mainVC). My static library will be built in some third party application.

I have to show mainVC.view instantly after third app did launch. I do:

[window addSubView:mainVC.view];

but how can I do my mainVC active? It means I have to deny landscape orientation in

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

and this method never calls in this case.

I've also tried to call manually

[self.mainVC viewWillAppear:NO];

but still unsuccessful.

Maybe I should use

-(void)presentModalViewController:animated

but it's deprecated. And I have to support IOS 4.3

Injectios
  • 2,777
  • 1
  • 30
  • 50

1 Answers1

0

You might want to check if the class is allowed to respond to the method before you call it.

if([self respondsToSelector:@selector(presentViewController:animated:completion:)]) 
{
    [self presentViewController:viewController animated:YES];
}
else
{
    //some other methods
}

This way you can use the deprecated method for support with IOS 4.3, and use another solution for later IOS versions

Totumus Maximus
  • 7,543
  • 6
  • 45
  • 69
  • 1
    The correct way would be to use `if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) [self presentViewController:viewController animated:animated completion:completionBlock]; else { ... }` – Fabian Kreiser Aug 20 '12 at 11:19
  • Noted: not as knowledgable of the 4.3 methods, so copied from his own question method. The idea remains the same if you want to have backwards compatibility – Totumus Maximus Aug 20 '12 at 11:33
  • Actually it's not exactly what I need. I have to show mainVC.view like a popup (Same like FBDialog does) and if I present mainVC modally and set mainVC.view margins... It has black area around my mainVC.view – Injectios Aug 20 '12 at 12:15