Pregunta

¿Es posible presentar un popover sin ningún tipo de flechas que apuntan en alguna parte?

¿Fue útil?

Solución

Sí, es posible simplemente hacer:

 [self.popoverController presentPopoverFromBarButtonItem:anItem   
                                permittedArrowDirections:0
                                                animated:YES];

El cero representan ninguna dirección.

Otros consejos

Para iPhone y rápida 2.0 prueba este

El código para iniciar popover

initiatePopover(){
    let popoverContent = self.storyboard?.instantiateViewControllerWithIdentifier("XYZController") as! XYZController
    let nav = UINavigationController(rootViewController: popoverContent)
    nav.modalPresentationStyle = UIModalPresentationStyle.Popover
    let popover = nav.popoverPresentationController
    popoverContent.preferredContentSize = CGSizeMake(250 ,200)
    popover!.delegate = self
    popover!.sourceView = self.view
    popover!.sourceRect = CGRectMake(200,200,0,0)
    popover!.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
    self.presentViewController(nav, animated: true, completion: nil)
}

Y agregar esto a su ViewController

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
    return UIModalPresentationStyle.None
}

Configurar el permittedArrowDirections a 0.

permittedArrowDirections:0

Código -

[self.popoverController presentPopoverFromBarButtonItem:anItem   
                                permittedArrowDirections:0
                                                animated:YES];

Cero dice "NoDirection".

Swift3 , este código funcione para mí

popover.permittedArrowDirections = .init(rawValue: 0)

En Swift 2.0 y iOS9 la solución es:

popoverViewController?.permittedArrowDirections = UIPopoverArrowDirection()

Prueba de esto, a mí me funciona.

[self.popoverViewController presentPopoverFromRect:rect inView:self.view  permittedArrowDirections:0 animated:YES];

Swift4

popover.permittedArrowDirections = []              

Esta bien que funciona para mí.

[popoverController presentPopoverFromRect:CGRectMake(0, 0, 20, 20)
                                    inView:self.view 
                  permittedArrowDirections:NULL 
                                  animated:YES];

Disfrute de Codificación.

No, no hay ninguna opción UIPopoverArrowDirectionNone y UIPopoverArrowDirectionUnknown lanza una excepción, creo que si se intenta utilizar eso para la actualidad.

En lugar de un controlador popover, puede llamar a presentModalViewController:animated: y ajustar el controlador que está presentando a tener un estilo de presentación modal del UIModalPresentationFormSheet o tal vez UIModalPresentationPageSheet. Esas son las pantallas emergentes más tradicionales que son panecillos.

En mi caso para los desarrolladores rápidos

popoverController.sourceView = self.view
popoverController.sourceRect = self.view.bounds
popoverController.backgroundColor = UIColor.brownColor()

popoverController.permittedArrowDirections = UIPopoverArrowDirection.init(rawValue: 0)
popoverController.sourceRect = CGRectMake(width/4, hieght/4, width/2, hieght/2);

En rápida 3, se puede construir una extensión UIPopoverArrowDirection para esto:

extension UIPopoverArrowDirection {
    public static var noArrow: UIPopoverArrowDirection {
        return UIPopoverArrowDirection(rawValue: 0)
    }
}

y el que puede hacer:

popoverPresentationController!.permittedArrowDirections = .noArrow

En Swift, sólo tiene que hacer:

popoverPresentationController.permittedArrowDirections = []

Dado que en otra configuración que podría haber utilizado:

popoverPresentationController.permittedArrowDirections = [.up, .down]

Prueba con esto

[popOverController presentPopoverFromRect:CGRectMake(0, 0, 30, 40) inView:popOverContentView permittedArrowDirections:0 animated:NO];

No utilice de Popovers si no desea mostrar flechas. Presentar su controlador de vista como un modal y utilizar un UIModalPresentationFormSheet lugar.

Ejemplo:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MyStoryBoard" bundle:nil];
UIViewController* viewController = [sb instantiateViewControllerWithIdentifier:@"myViewController"];
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
[presenterViewController presentViewController: viewController animated:YES completion:^{

}];

Yo uso popover al menú espectáculo, según el toque de coordenadas. En este caso popover utiliza la altura máxima de self.view

CGRect popeverFrame = CGRectMake(touchPoint.x, touchPoint.y, 0, 0);
[self.popover presentPopoverFromRect:popeverFrame
                              inView:self.view
            permittedArrowDirections:UIPopoverArrowDirectionAny
                            animated:YES];

Pero cuando se utiliza 0-dirección. rectángulo Popover no establece que la altura al máximo y sólo se puede ajustar por la propiedad adecuada.

CGRect popeverFrame = CGRectMake(touchPoint.x, touchPoint.y, 0, 0);
[self.popover presentPopoverFromRect:popeverFrame
                              inView:self.view
            permittedArrowDirections:UIPopoverArrowDirectionAny
                            animated:YES];

Esperamos que esto ayude: con el tamaño UIPopOverController

Para hacer un pop sobre la dirección ninguno y hacer que aparezca en el centro del controlador de vista:

let PopSrnVar = popoverPresentationController
let ConRctVar = view.frame
PopSrnVar!.sourceRect = CGRectMake(ConRctVar.width/4, ConRctVar.height/4, ConRctVar.width/2, ConRctVar.height/2)
// To make arrows as none
PopSrnVar!.permittedArrowDirections = UIPopoverArrowDirection()

Una solución simple en SWIFT:

popover!.permittedArrowDirections = nil
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top