我想在UIPopoverArrowDirectionLeft
. 如何在单击按钮时将图像显示为弹出窗口?
问问题
1760 次
3 回答
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];
}
}
于 2013-02-12T10:00:22.417 回答
0
实现此场景的另一种方法是根据您的需求制作自定义 uiview,并在其中设置要显示为弹出框的图像。并在您想要显示弹出框时显示它。
于 2014-03-12T07:23:35.877 回答
0
像 WEPopOverController 一样使用自定义 popOverViewController。它包含一些属性来更改弹出箭头图像等。
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 your Image
ret.leftArrowImageName = @"popoverArrowLeftSimple.png";
ret.rightArrowImageName = @"popoverArrowRightSimple.png";
return ret;
}
于 2013-02-12T10:57:00.343 回答