在photoscroller应用程序(iPhone WWDC-104 Photos App)中,当使用presentModalviewController调用时,uiscrollview图像会向右移动 [英] In photoscroller app (iPhone WWDC-104 Photos App) uiscrollview images shift to right when called using presentModalviewController

查看:90
本文介绍了在photoscroller应用程序(iPhone WWDC-104 Photos App)中,当使用presentModalviewController调用时,uiscrollview图像会向右移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过WWDC-104视频,其中显示了照片的UIScrollView. 我也下载了示例代码. 在我的应用中,结构如下,

I have seen the WWDC-104 video showing UIScrollView for photos. I have downloaded the Sample code too. In my app the Structure is as follows,

(根类)A类---> B类-----------> PhotoViewController(包含ScrollView)

(Root Class)Class A ---> Class B -----------> PhotoViewController(Containing ScrollView)

我正在使用B类中的presentModalViewController方法来调用PhotoViewController类.

I am calling the PhotoViewController class by using presentModalViewController method in Class B.

但是,每滑动一次,新图像就会在视图上向右移动. 图像左侧可见黑色垂直条,每次滑动都会变宽. 因此,在6到8张图像后,视图会变成全黑.

But with every swipe the new Image shifts to right on the view. A black vertical strip is visible on left of the image which widens with each swipe. So after 6 to 8 images the view becomes totally black.

我还没有编写任何其他代码.刚刚复制了课程.

I have not written any other code. Just copied the classes.

当PhotoViewController类不是要加载的第一个类时,为什么会发生这种情况? 是否需要为ScrollView设置任何属性? 此视图层次结构中是否有任何错误?

Why this happens when the PhotoViewController class is not the first class to be loaded? Is there any property that needs to be set for ScrollView ? Is there any mistake in this view Hierarchy?

还如何从特定图片开始(从第10张图片开始加载)?

Also How to start from a particular image (Load from 10th image)?

我们将不胜感激任何帮助/建议.

Any help/suggestion will be highly appreciated.

第一次水平滑动后,

第二次水平滑动后,

推荐答案

在应用程序中使用它时,不是由UINavigationController推送的PhotoViewController吗?

Isn't your PhotoViewController pushed by a UINavigationController when you use it in your application ?

那是问题,NavigationController修改ScrollView的框架,并且一旦视图出现,由PhotoViewController创建的偏移和扩展宽度就不再存在.

That's the problem, the NavigationController modifies the frame of the ScrollView and the offset and extended width created by PhotoViewController is not longer there once the view appears.

解决此问题的最简单方法是将PhotoViewController的视图设置为常规UIView,然后将ScrollView添加为该UIView的子视图.然后NavigationController将修改此视图的框架,但不会触摸子视图.

The easiest way to fix this is to set the view of PhotoViewController to a regular UIView and add the ScrollView as a subview of this UIView. Then the NavigationController will modify the frame of this view but it will not touch the subview.

UIView * intermediateView = [[UIView alloc] initWithFrame:pagingScrollViewFrame];
[intermediateView addSubview:pagingScrollView];
self.view = intermediateView;

有关更多信息,请查看此问题: 在具有pageingEnabled的UIScrollView中页面之间的类似照片应用程序的间隙

Have a look at this question for more info: Photos app-like gap between pages in UIScrollView with pagingEnabled

这篇关于在photoscroller应用程序(iPhone WWDC-104 Photos App)中,当使用presentModalviewController调用时,uiscrollview图像会向右移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆