我想在UIPopoverArrowDirectionLeft
上显示图片。如何在按钮点击时将图像显示为弹出窗口?
答案 0 :(得分:1)
我认为你的意思是弹出窗口会打开,里面有一个图像。 这是如何做到的,只需以编程方式将图像添加到弹出窗口视图中,或者更好的是,直接在界面构建器中将图像添加到MyPopOverView XIB
- (IBAction)showPopover:(id)sender
{
if(![popoverController isPopoverVisible]) {
myPopOver = [[MyPopOverView alloc] initWithNibName:@"MyPopOverView" bundle:nil];
popoverController = [[UIPopoverController alloc] initWithContentViewController:myPopOver] ;
// THE IMAGE
UIImageView *icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"popoverImage.png"]];
[popoverController addsubview:icon];
[popoverController setPopoverContentSize:CGSizeMake(350.0f, 500.0f)];
[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
[popoverController dismissPopoverAnimated:YES];
}
}
答案 1 :(得分:0)
使用自定义popOverViewController与WEPopOverController类似。它包含一些属性来更改弹出箭头图像等。
http://www.cocoacontrols.com/controls/wepopover
- (WEPopoverContainerViewProperties *)defaultContainerViewProperties {
WEPopoverContainerViewProperties *ret = [[WEPopoverContainerViewProperties new] autorelease];
CGSize imageSize = CGSizeMake(30.0f, 30.0f);
NSString *bgImageName = @"tri123.png";//@"round-rect-box.png";
CGFloat bgMargin = 2.0;
CGFloat contentMargin = 2.0;
ret.leftBgMargin = bgMargin;
ret.rightBgMargin = bgMargin;
ret.topBgMargin = bgMargin;
ret.bottomBgMargin = bgMargin;
ret.leftBgCapSize = imageSize.width/2;
ret.topBgCapSize = imageSize.height/2;
ret.bgImageName = bgImageName;
ret.leftContentMargin = contentMargin;
ret.rightContentMargin = contentMargin;
ret.topContentMargin = contentMargin;
ret.bottomContentMargin = contentMargin;
ret.arrowMargin = 1.0;
ret.upArrowImageName = @"popoverArrowUpSimple.png";
ret.downArrowImageName = @"tri2.png"; // Customize ur Image
ret.leftArrowImageName = @"popoverArrowLeftSimple.png";
ret.rightArrowImageName = @"popoverArrowRightSimple.png";
return ret;
}
答案 2 :(得分:0)
实现此方案的另一种方法是根据您的要求制作自定义uiview,并在其中设置要显示为弹出窗口的图像。并在你想要展示你的popover时显示它。