English 中文(简体)
xcode中的图像数组[已关闭]
原标题:image array in xcode [closed]
  • 时间:2010-10-18 07:13:12
  •  标签:
  • iphone
  • ios
Closed. This question needs to be more focused. It is not currently accepting answers.

想改进这个问题吗 通过编辑此文章更新问题,使其仅关注一个问题。

Closed 5 years ago.

我是iphone编程的新手,我想为slideview放置多个图像。。为此,我想通过数组声明它,并在同一个viewcontroller类中使用它。。这样任何人都可以告诉我如何声明类中的图像数组并显示

问题回答

如果你只有几张图片,博友的解决方案很好,但多张图片需要更复杂的解决方案,尤其是如果图片的分辨率更高(如果你想放大,你需要这样做)。图像可能会消耗大量内存,因此您需要一种策略,在任何特定时刻只加载所需的图像,并在不再需要时卸载它们。UIScrollView提供了平铺内容,因此您可以一次只提供一点滚动内容。这可以让你在内存中只保留你需要的东西,同时还能提供不错的滚动性能。

看看PhotoScroller示例代码,了解如何做好这项工作。

One solution for the scrollview is to create an UIImageView for every picture you want to add to your scrollview and then add them as subviews to your scrollview.
As far as for the tap part - you can create your own GestureRecognizer for the tap action and set anything you want to do with the selected image. Also try to change minzoom and maxzoom of the scrollview s contentview and zoom action will be added automatically for you.

NSArray *images = [NSArray arrayWithObjects:
                   [UIImage imageNamed:@"1.png"],
                   [UIImage imageNamed:@"2.png"],
                   [UIImage imageNamed:@"3.png"],
                   [UIImage imageNamed:@"4.png"],
                   [UIImage imageNamed:@"5.png"],
                   nil];      




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签