English 中文(简体)
presenting modal views in a popover
原标题:

Im trying to load a modal view from a view controller that is displayed in a popover. The modal view loads but the problem is that it transitions into the main view and not within the popover. Is it something Im missing? I thought simply initiating it from a vc within a popover would present the modal view within the same popover...

The code is nothing special as bellow:

- (IBAction)myButton{
ModalVC *controller = [[ModalVC alloc] initWithNibName:@"ModalVC" bundle:nil];

[self presentModalViewController:controller animated:YES];
[controller release]; }
问题回答

If you add

controller.modalPresentationStyle = UIModalPresentationCurrentContext;

before the call to presentModalViewController:animated your ModalVC should be displayed within the popover.

Another way to display something modally in a popover is to use the property modalInPopover.

Unfortunately, it seems you cannot to this and it violates the HIG. From Apple s View Controller Programming Guide

Note: You should always dismiss the visible popover before displaying another view controller modally. For specific guidelines on when and how to use popovers in your application, see “Popover (iPad Only)” in iOS Human Interface Guidelines.

It s because you presentModalViewController to self. Try to add a UIBarButtonItem in your ViewController (self) and do:

[controller presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

where sender is the UIBarButtonItem





相关问题
Program received signal EXC BAD ACCESS

I m stuck with a problem in emulator. The emulator occasionally stops with Program received signal: "EXC_BAD_ACCESS" . as console output. No further info provided. Is there a chance to come closer ...

Controlling Number of Application Executions

Is there a way to control the number of times an iPhone app executes. For example, I have a game called widget and I only want the user to play the game (new instance) no more that 20. Also, if tis ...

XCode - Multiple targets, Multiple *internationalized* names?

I ve got an internationalized iPhone project. In the various ${lang}.lproj/InfoPlist.strings files I ve got a single key, CFBundleName = "My App Name". That s working fine for a single target, but I ...

strange iphone sdk sqlite memory leak

I have a very strange memory leak problem, it seems that sqlite3_step is doing some nasty stuff :| I spent almost 4 hours trying to fix this but no luck till now :( Here it is the code: [dbList ...

热门标签