开发者

ipad UIPopoverController with UINavigationController

开发者 https://www.devze.com 2023-02-27 04:26 出处:网络
How can I create a UIPopoverController with integrated UINavigationController so I will be able to slide views inside the UIPopoverController left-right (with navigation bar).

How can I create a UIPopoverController with integrated UINavigationController so I will be able to slide views inside the UIPopoverController left-right (with navigation bar).

UPDATE: I open popup like this

- (void)showSettingsViewAtSenderForIPad:(id)sender
{
    if (!settingsPopoverController_) 
    {
        SettingsPopoverController *settings = [[SettingsPopoverController alloc] init];
        settings.valuesGeneratorOptions = valuesGeneratorOptions_; // setting variables

        self.settingsPopoverController_ = [[[UIPopoverController alloc] initWithContentViewController:settings] autorelease];
        [settingsPopoverController_ setDelegate:self];
        [settingsPopoverController_ setPopoverContentSize:CGSizeMake(320, 480)];

        [settings release];
    }

    if (!infoPopoverController_.popoverVisible) 
    {
        [settingsPopoverController_ presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
    }
}

I created a controller which has a NSTableViewController as a root controller in UINavigationController

@interface SettingsPopoverController : UIViewController 
{
    ValuesGeneratorOptions *valuesGeneratorOptions;
    IBOutlet SettingsViewController *settingsViewController;
    IBOutlet UINavigationController *navigationController;
}
...
@implementation SettingsPopoverController
...
- (void)viewDidLoad
{
   开发者_JAVA百科 self.settingsViewController.valuesGeneratorOptions = self.valuesGeneratorOptions;
    [self.view addSubview:self.navigationController.view];

    [super viewDidLoad];
}
...
end

The problem is, that the table is not scrollable inside the popup. It also ignores the table style (initWithStyle not called). Fix?

SOLUTION: Found the solution: popOver table view


You create a new nib and a UIViewController. This nib has, as it's top level view, a plain jane UIView and a UINavigationController. The UINavigationController's top UIViewController is whatever view controller you want to display first.

You then display this nib inside your popover controller. In the view did load, you do something like this:

-(void)viewDidLoad
{
    [self.view addSubview:self.navigationController.view];
}

This adds your navigation controller's view to your view in your nib, which allows it to be displayed.

0

精彩评论

暂无评论...
验证码 换一张
取 消