我想在UIPopoverArrowDirectionLeft上显示图像。单击按钮后如何将图像显示为弹出窗口?

最佳答案

我认为您的意思是打开一个带有内部图像的弹出窗口。
这是这样做的方法,只需以编程方式将图像添加到弹出视图,或者更好的是,直接在界面构建器中将图像添加到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];
    }
}

关于ios - 将图片显示为弹出框,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14829670/

10-11 00:37