iphone - 如何制作 UIScrollView 图片库? (iPhone SDK)

标签 iphone sdk uiimageview gallery

我一直在努力尝试让 UIImageView 在 UIScrollView 滚动时更改其图像,有点像 Photos.app。

这是我的代码:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (scrollView.contentOffset.x > 296){
        self.currentDBNum++;
        self.currentDoorbell = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[[self.doorbells objectAtIndex:currentDBNum] objectForKey:@"Image"] ofType:@"jpg"]];
        self.doorbellPic.image = currentDoorbell;
        self.currentSoundPath = [[NSBundle mainBundle] pathForResource:[[doorbells objectAtIndex:currentDBNum] objectForKey:@"Sound"] ofType:@"caf"];

    }
}

有什么提示吗?谢谢。 (图像的宽度为 296。)

最佳答案

有两种方法可以完成您的任务:

  1. 尝试学习T hree20 TTPhotoViewController这将与您在 iPhone 中看到的 photo.app 完全相同。
  2. 如果你想自己做,那么根据我的经验,你必须将多个具有正确位置(x,y,宽度,高度)的 UIImageView 添加到 UIScrollView 中。请记住使用正确的内容大小初始化 ScrollView ,以便它可以滚动。一个例子:image1是(0,0,320,480),image2是(320,0,320,480),image3是(640,0,320,480),等等...那么你的 ScrollView 内容大小将是最后一项的x值+宽度最后一项。

关于iphone - 如何制作 UIScrollView 图片库? (iPhone SDK),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2291963/

相关文章:

ios - 如何仅从共享扩展启动应用程序而无需在 Swift 中弹出弹出窗口?

android - Honeycomb 预览 - 无法在 Eclipse 下的模拟器上安装我的应用程序

ios - 如何从 UIImageView 上传图片到 Parse.com

iphone - 如何制作一个圆形的UIView

c++ - 报错:access violation when I use StartServiceCtrlDispatcher(entrytable)

swift - 点击事件不会在动画 ImageView 上触发

ios - 如果已安装,如何将用户发送到 facebook 应用程序上的 facebook 页面?

iphone - Cocoa Touch 中的线条平滑

iphone - 保存事件执行的当前时间

android - 未经授权的设备 - 不允许从此设备付款