Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone - presentModalViewController via UITabBarItem and dismissModalViewController cleanly
    text
    copied!<p>I have a <code>tabBarController</code> that I add by placing the following code into:</p> <p><strong>AppDelegate.h:</strong></p> <pre><code> ... UITabBarController IBOutlet *tabBarController; } @property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; </code></pre> <p><strong>AppDelegate.m:</strong></p> <pre><code> ... [self.window addSubview:tabBarController.view]; [self.window makeKeyAndVisible]; [tabBarController setDelegate:self]; </code></pre> <p><strong>I then use the following code to present a modal barcode scanning View Controller:</strong></p> <pre><code>- (void)tabBarController:(UITabBarController *)tbc didSelectViewController:(UIViewController *)vc { // Middle tab bar item in question. if (vc == [tabBarController.viewControllers objectAtIndex:2]) { ScanVC *scanView = [[ScanVC alloc] initWithNibName:@"ScanViewController" bundle:nil]; // set properties of scanView's ivars, etc UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:scanView]; [tabBarController presentModalViewController:navigationController animated:YES]; [navigationController release]; [scanView release]; } } </code></pre> <p>When it does actually get presented I think this method isn't visually appealing, because when I dismiss the modal view I am brought back to an empty view.</p> <p>A lot of barcode scanning applications or applications that simply display an image picker for example; do this quite successfully. I'm just wondering what kind of implementation they would use in order to achieve such an effect.</p> <p>This is a screenshot of an application called <em>Path</em>, which has the exact same functionality I'm after:</p> <p><img src="https://i.stack.imgur.com/0a7PX.png" alt="alt text"></p> <p>I also noticed that in these applications, if you are on any other tab bar item other than the middle one let's say, and you click on the tab bar item that presents the modal view, once it gets dismissed it doesn't actually bring them back to an empty view it dismisses like normal, however the actual tab bar item that presents the modal view is never selected. I would be happy with this type of functionality if that's the only way to implement this type of effect.</p> <p>Any help would be greatly appreciated as I've been stuck in this for quite some time. Also I'm not even sure whether it's the right way to put all of this code in my <code>AppDelegate</code> in order for the View Controller to be presented as a modal. It all seems, just, wrong.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload