在弹出窗口中显示多个图像

发布于 2024-11-14 22:10:20 字数 208 浏览 1 评论 0原文

我的图像视图顶部有一个按钮。 单击按钮时,我需要在视图中显示多个图像;这个视图就像一个小弹出窗口。谁能告诉我一种好方法来做到这一点?

我认为在 UITableView 中显示多个图像看起来像是一个设计问题。谁能告诉我 Objective-C 中是否有任何控件可以在小弹出窗口中显示图像?

另外,当我单击弹出窗口时,我需要获取图像名称/详细信息。

I have a button on the top of my image view.
I need to display multiple images in a view when the button is clicked; this view will be like a small popup. Can any one tell me a good way to do this?

I think showing multiple images in a UITableView will look like a design problem. Can any one tell me if there are any controls in Objective-C to display images in small popup?

Also, I need to get the image name/details when I click in the pop up.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

渔村楼浪 2024-11-21 22:10:20

您想要在该视图中显示图像——您很可能希望使用 UIImageView 实例来初始化它。如果你有一定数量的图片,你可以在 IB 中按照你喜欢的方式对齐它们,但如果它们发生变化,你就必须在代码中动态地进行调整。

因此,当您创建视图来显示图像时,您需要将数组中的图像传递到显示它们的视图控制器。使用数组的计数,您可以计算出要创建多少个 UIImageView 实例(并设置一些逻辑,以便在屏幕上显示它们的方式/位置)。然后您需要将图像设置到各自的图像视图中。为了通过点击来获取图像信息,您需要向每个图像视图添加一个手势识别器,以便在点击时调用一个方法。您可以对每个图像使用相同的方法并标记图像视图以了解您正在查看哪个。例如:

- (void)imageViewTapped:(UIGestureRecognizer *)gesture {
    int myImageTag = [gesture.view tag];  // this will return the tag of the imageView it is associated with
    // get infomation about it's image ([gesture.view image] will give you the UIImage in it)
    //any other code you may want to implement;
}

这就是您听起来想要做的事情背后的逻辑。应该不会太难,但我希望这对你有帮助

This view where you want to display the images -- you will most likely want to initialize it with UIImageView instances. If you had a set amount of pictures, you could just align them how you like within IB, but if they change, you'll have to do it dynamically within the code.

So when you are creating the view to display your images, you'll want to pass the images in an array to your view controller that displays them. Using the count of the array, you can figure out how many UIImageView instances to create (and set up some logic how/where you want to display them on the screen). Then you will want to set the images into their respective image views. In order to tap to get information on the images, you'll want to add a gesture recognizer to each image view that calls a method when tapped. You can use the same method for each and tag the image views to know which you are looking at. for example:

- (void)imageViewTapped:(UIGestureRecognizer *)gesture {
    int myImageTag = [gesture.view tag];  // this will return the tag of the imageView it is associated with
    // get infomation about it's image ([gesture.view image] will give you the UIImage in it)
    //any other code you may want to implement;
}

That's pretty much the logic behind what it sounds like you'll want to do. It shouldn't be too hard, but I hope this helps you out

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文