3
votes

I am currently developing an iPhone App for my company and i ran into a strange thing.

My View Hierachy looks like this:

UITabBarController containing 5 Tabs with every Tab containing a UINAvigationController. So far everything works perfect.

Now i want to present a modal View controller via the presentModalViewController method on the UITabBarController using this lines of code:

-(void)callFilterOptions
{
    FilterOptionsView *filterView = [[FilterOptionsView alloc] init];
    [filterView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self.tabBarController presentModalViewController:filterView animated:TRUE];
}

The FilterOptionsView is a normal UIViewController containing nothing but a black background at the moment.

What happens is that the view is presented and after a couple of seconds misteriously disappears. Why is this happening? At no Point i am calling the dismissModalViewController method.

I already ran into this problem when presenting a mailcomposer.

greetings, Florian

1
Try changing self.tabBarController for [self.view presentModalViewController:filterView animated:TRUE];oriolpons
The same error occurs. And i can not present the modal view controller from a View so i tried [self presentModalViewController:filterView animated:TRUE];user1197467
are you using ARC? try to make your filterView as a Class variableChakalaka

1 Answers

0
votes
UINavigationController *myNavController = [self navigationController];
[myNavController presentModalViewController:filterView animated:TRUE];

or a better approach might be:

UIApplication *myApp = [UIApplication sharedApplication];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate.tabBarController presentModalViewController:filterView animated:YES];

to dismiss:

UIApplication *myApp = [UIApplication sharedApplication];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate.tabBarController dismissModalViewControllerAnimated:YES];

p.s. I recommend not naming a view controller "filterView" it would be better named "filterViewController"