Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>////////////////////////////////////////</p> <p>////////////<strong>**<em>SOLUTION</em>**</strong>////////</p> <p>////////////////////////////////////////</p> <p>I'm gonna edit this post because i solved my problem and I think could be helpful share my solution here:</p> <p><strong>first of all</strong>, follow this sample:</p> <p><a href="http://mobiforge.com/designing/story/using-popoverview-ipad-app-development">http://mobiforge.com/designing/story/using-popoverview-ipad-app-development</a></p> <p>When It is done go to step two.</p> <p><strong>The second step</strong> will be add a new popoverBackgroundViewClass:</p> <p>Add new file in your project Objective class and call it 'CustomPopoverBackgroundView'</p> <pre><code>/////////////////////////////////////////////// ////// CustomPopoverBackgroundView.h ///////// /////////////////////////////////////////////// #import &lt; UIKit/UIKit.h &gt; #import &lt; UIKit/UIPopoverBackgroundView.h &gt; @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 </code></pre> <p><strong>Third step:</strong></p> <p>When It is done add this line in 'PopOverExample1ViewController.m':</p> <p>import the new class:</p> <pre><code>#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]; } </code></pre> <p>Alright!!! Thats all! If someOne needs help just let me know. Best wishes!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload