ejemplo content bootstrap ipad uinavigationcontroller uipopovercontroller

ipad - content - cambiar el controlador de navegación de color en un popover



popover bootstrap 4 (2)

////////////////////////////////////////

//////////// ** SOLUCIÓN ** ////////

////////////////////////////////////////

Voy a editar esta publicación porque he resuelto mi problema y creo que podría ser útil compartir mi solución aquí:

antes que nada , sigue esta muestra:

http://mobiforge.com/designing/story/using-popoverview-ipad-app-development

Cuando termine, vaya al paso dos.

El segundo paso será agregar un nuevo popoverBackgroundViewClass:

Agregue un nuevo archivo en su clase de objetivo de proyecto y llámelo ''CustomPopoverBackgroundView''

/////////////////////////////////////////////// ////// CustomPopoverBackgroundView.h ///////// /////////////////////////////////////////////// #import < UIKit/UIKit.h > #import < UIKit/UIPopoverBackgroundView.h > @interface CustomPopoverBackgroundView : UIPopoverBackgroundView{ UIPopoverArrowDirection direction; CGFloat offset; } @end ////////////////////////////////////////////// ////// CustomPopoverBackgroundView.m ///////// ////////////////////////////////////////////// #import "CustomPopoverBackgroundView.h" @implementation CustomPopoverBackgroundView - (void)layoutSubviews { [super layoutSubviews]; CGFloat fullHeight = self.frame.size.height; CGFloat fullWidth = self.frame.size.width; CGFloat startingLeft = 0.0; CGFloat startingTop = 0.0; CGFloat arrowCoord = 0.0; UIImage *arrow; UIImageView *arrowView; switch (self.arrowDirection) { case UIPopoverArrowDirectionUp: startingTop += 13.0; fullHeight -= 13.0; //the image line.png will be the corner arrow = [UIImage imageNamed:@"line.png"]; arrowCoord = (self.frame.size.width / 2) - self.arrowOffset; arrowView = [[[UIImageView alloc] initWithFrame:CGRectMake(arrowCoord, 0, 13.0, 13.0)] autorelease]; break; case UIPopoverArrowDirectionDown: fullHeight -= 13.0; arrow = [UIImage imageNamed:@"line.png"]; arrowCoord = (self.frame.size.width / 2) - self.arrowOffset; arrowView = [[[UIImageView alloc] initWithFrame:CGRectMake(arrowCoord, fullHeight, 13.0, 13.0)] autorelease]; break; case UIPopoverArrowDirectionLeft: startingLeft += 13.0; fullWidth -= 13.0; arrow = [UIImage imageNamed:@"line.png"]; arrowCoord = (self.frame.size.height / 2) - self.arrowOffset; arrowView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, arrowCoord, 13.0, 13.0)] autorelease]; break; case UIPopoverArrowDirectionRight: fullWidth -= 13.0; arrow = [UIImage imageNamed:@"line.png"]; arrowCoord = (self.frame.size.height / 2) - self.arrowOffset; arrowView = [[[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width-13.0, arrowCoord, 13.0, 13.0)] autorelease]; break; } //this image will be your background UIImage *bg = [[UIImage imageNamed:@"lineBack.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(8.0, 8.0, 8.0, 8.0)]; UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(startingLeft, startingTop, fullWidth, fullHeight)] autorelease]; [imageView setImage:bg]; [arrowView setImage:arrow]; [self addSubview:imageView]; [self addSubview:arrowView]; } - (CGFloat) arrowOffset { return offset; } - (void) setArrowOffset:(CGFloat)arrowOffset { offset = arrowOffset; [self setNeedsLayout]; } - (UIPopoverArrowDirection)arrowDirection { return direction; } - (void)setArrowDirection:(UIPopoverArrowDirection)arrowDirection { direction = arrowDirection; [self setNeedsLayout]; } + (CGFloat)arrowHeight { return 30.0; } + (CGFloat)arrowBase { return 30.0; } + (UIEdgeInsets)contentViewInsets { return UIEdgeInsetsMake(30.0, 30.0, 30.0, 30.0); } @end

Tercer paso:

Cuando finalice, agregue esta línea en ''PopOverExample1ViewController.m'':

importar la nueva clase:

#import " CustomPopoverBackgroundView.h " -(IBAction) showMovies:(id) sender { if (self.popoverController == nil) { MoviesViewController *movies = [[MoviesViewController alloc] initWithNibName:@"MoviesViewController" bundle:[NSBundle mainBundle]]; UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:movies]; popover.delegate = self; [movies release]; //THIS IS THE LINE THAT YOU HAVE TO ADD popover.popoverBackgroundViewClass=[CustomPopoverBackgroundView class]; self.popoverController = popover; [popover release]; } [self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } -(IBAction) btnShowMovies:(id) sender { if (self.popoverController == nil) { MoviesViewController *movies = [[MoviesViewController alloc] initWithNibName:@"MoviesViewController" bundle:[NSBundle mainBundle]]; UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:movies]; popover.delegate = self; [movies release]; //THIS IS THE LINE THAT YOU HAVE TO ADD popover.popoverBackgroundViewClass=[CustomPopoverBackgroundView class]; self.popoverController = popover; [popover release]; } CGRect popoverRect = [self.view convertRect:[btn frame] fromView:[btn superview]]; popoverRect.size.width = MIN(popoverRect.size.width, 100); [self.popoverController presentPopoverFromRect:popoverRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; }

¡¡¡Bien!!! ¡Eso es todo! Si alguien necesita ayuda, házmelo saber. ¡Los mejores deseos!

Tengo un problema al tratar de cambiar el color de mi controlador de navegación dentro de mi popoverController.
Estoy tratando de hacer algo como esto:

if (self.popoverController == nil) { ArtistsViewController *artistsViewController = [[ArtistsViewController alloc] initWithNibName:@"ArtistsViewController" bundle:[NSBundle mainBundle]]; artistsViewController.navigationItem.title = @"Artists"; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:artistsViewController]; UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:artistsViewController.navigationController]; artistsViewController.navigationController.navigationBar.tintColor=[UIColor greenColor]; popover.delegate = self; [artistsViewController release]; [navController release]; self.popoverController = popover; [popover release]; } [self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

pero no funciona. ¿alguna sugerencia?


override func viewDidAppear(_animated: Bool){ let navigationBar = self.navigationController?.navigationBar navigationBar?.tintColor = UIColor(colorLiteralRed: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)

el color de la barra de botones

navigationBar?.barStyle = UIBarStyle.black

la barra de estilo

navigationBar?.barTintColor = UIColor(colorLiteralRed: 0.89, green: 0.55, blue: 0.69, alpha: 1.0)

el color de la barra

let imageView(frame: CGRect(x: 0, y: 0, width: 250, height: 80)) imageView.contentMode = .scaleAspectFit }

barra de imagen

todo el código

override func viewDidAppear(_animated: Bool) { let navigationBar = self.navigationController?.navigationBar navigationBar?.tintColor = UIColor(colorLiteralRed: 1.0, green: 1.0, blue: 1.0, alpha: 1.0) navigationBar?.barStyle = UIBarStyle.black navigationBar?.barTintColor = UIColor(colorLiteralRed: 0.89, green: 0.55, blue: 0.69, alpha: 1.0) let imageView(frame: CGRect(x: 0, y: 0, width: 250, height: 80)) imageView.contentMode = .scaleAspectFit }