2016-04-17 13 views
1

Ich versuche Popover mit UIPopoverPresentationController Klasse auf dem iPhone zu präsentieren. Ich muss Navigation Controller im Popover präsentieren. So mache ich folgendes:UIPopoverPresentationController kann keine Pfeilfarbe einrichten

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController]; 
    viewController.preferredContentSize = size; 
    navigationController.modalPresentationStyle = UIModalPresentationPopover; 
    self.currentPopoverController = navigationController.popoverPresentationController; 
    self.currentPopoverController.backgroundColor = [UIColor commonApplicationBgColor];//My common app blue color 
    self.view.alpha = 0.7; 
    [self presentViewController:navigationController animated:YES completion:nil]; 

Es funktioniert, aber Farbe Pfeil aus der popover Navigationsleiste Hintergrundfarbe unterscheiden. Ich habe überprüft, dass sie die gleiche [UIColor commonApplicationBgColor] verwenden, aber es sieht so aus, als wäre die Pfeilfarbe dunkler. Versuchte Setup-Alpha für self.currentPopoverController.backgroundColor, aber es hat immer noch die falsche Farbe. Bitte überprüfen Bild: enter image description here

+0

Sind Sie es von rect zu präsentieren? – Lion

+0

Ja, hier ist der Code: self.currentPopoverController.delegate = self; self.currentPopoverController.sourceView = self.view; self.currentPopoverController.sourceRect = Rahmen; –

+0

Popover funktioniert seit iOS 7 nicht mehr sehr gut. Apple verwendet das nicht sehr oft in seinen eigenen Anwendungen und das ist das Ergebnis. – Sulthan

Antwort

-1

wenn Sie nicht Pfeil wollen, dann können Sie 0-permittedarrowdirection passieren wie

[popoverController presentPopoverFromRect:YOUR_RECT 
           inView:self.view 
       permittedArrowDirections:0 
           animated:YES]; 

Update:

Sie können wie eingestellt,

popover = [[UIPopoverController alloc] initWithContentViewController:contentViewController]; 
popover.backgroundColor = contentViewController.view.backgroundColor; 

Setzen Sie bacground color auf popovercontroller.

Update 2:

myPopoverViewController.modalPresentationStyle = UIModalPresentationPopover; 
[self presentViewController:myPopoverViewController animated: YES completion: nil]; 

// Get the popover presentation controller and configure it. 
UIPopoverPresentationController *presentationController = 
    [myPopoverViewController popoverPresentationController]; 
presentationController.permittedArrowDirections = 
    UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight; 
    presentationController.sourceView = myView; 
presentationController.sourceRect = sourceRect; 

presentationController.backgroundColor = [UIColor grayColor]; //set your expacted color here. 

Hope this helfen

+1

Nein, ich brauche einen Pfeil. Das Problem ist in Popover Pfeil Hintergrundfarbe. Die Farbe ist dunkler als die Farbe der Popover-Navigationsleiste. Bitte überprüfen Sie das Bild. –

+0

Ist es iPad Version? Überprüfen Sie bitte meinen Code, ich benutze popoverPresentationController –

+0

Sorry, zuerst habe ich iPad PopoverController verstanden. Ich habe meine Antwort aktualisiert. – Lion

Verwandte Themen