TTPhotoViewController:滑动之前图像不会加载
我正在尝试在示例 iPad 应用程序中实现 TTPhotoViewController 。我已经正确实现了 TTPhotoSource
和 TTPhoto
协议。 TTPhotoViewController
确实显示图像,但只有在滑动时才会显示图像。
下面标签栏中的左右按钮似乎根本不起作用,它们永远不会改变显示的图像。当到达最后一个或第一个图像时,UIActivityIndicatorView
永远不会被放置,左右按钮也不会被验证。
我正在将 TTPhotoViewController 的子类初始化为 UINavigationController 对象的 rootViewController,并将其添加到视图中。
这排除了这里面临的问题的可能性: http://third20.stackexchange.com/questions/78/ ttphotoviewcontroller-not-loading-images-immediately
我还缺少什么?有人遇到过类似的问题并找到解决方法吗?
谢谢, 拉杰
I am trying to implement TTPhotoViewController
in a sample iPad application. I have implemented properly TTPhotoSource
and TTPhoto
protocols. The TTPhotoViewController
does show image, but not until swiped.
The right and left button in the tab bar below doesnt seem to work at all, they never change the image displayed. The UIActivityIndicatorView
is never put up, nor the right and left buttons are validated when last or first images are reached.
I am initializing the subclass of TTPhotoViewController
as a rootViewController of a UINavigationController
object which I am adding it onto a view.
This rules out the possibility of the problem faced here:
http://three20.stackexchange.com/questions/78/ttphotoviewcontroller-not-loading-images-immediately
What else am I missing? Anybody faced similar problems and found a way around?
Thanks,
Raj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您很可能重写了
TTPhotoViewController
子类中的viewWillAppear
方法,但忘记调用 super 方法。You have most likely overriden the
viewWillAppear
method in yourTTPhotoViewController
subclass but forgot to call the super method.有同样的问题。 TTPhotoSource 完成加载后需要将 modelDidFinishLoad: 发送给其委托...否则,TTPhotoViewController 会认为它尚未准备好。
然而,这还不是全部。特别是在加载本地图像时,您的照片源可能会在 TTPhotoViewController 注册为委托之前完成加载。因此,您需要检查添加到 TTPhotoSource 的委托,如果在添加委托时加载完毕,则向它们发送 modelDidFinishLoad: 消息。
如果您继承自 TTModel,那么说起来容易做起来难,因为没有办法注册 NSMutableArray 来找出它何时发生更改。
所以...将以下代码添加到您的 TTPhotoViewController 子类中...
这将创建一个名为 superDelegates 的“虚拟”属性,它只是一个 NSArray,而不是 NSMutableArray。 insertObject:inSuperDelegatesAtIndex: 和removeObjectFromSuperDelegatesAtIndex: 方法,因为它们的名称包含“superDelegates”属性的名称,允许键值编码函数(您自动拥有该函数,因为它是非正式协议) mutableArrayValueForKey: 合成符合以下条件的代理对象NSMutableArray,它允许通过将突变操作转换为对 insertObject:inSuperDelegatesAtIndex: 和 removeObjectFromSuperDelegatesAtIndex: 方法的调用来编辑 superDelegates 属性。
然后,您所要做的就是重写“委托”方法以返回这样生成的代理,然后所有数组更改都会通过您运行,从而允许您在 TTPhotoViewController 附加自身时发送正确的加载通知。
Had the same problem. The TTPhotoSource needs to send modelDidFinishLoad: to its delegates when it has finished loading... otherwise, TTPhotoViewController assumes it's not ready yet.
That's not all, however. Especially when loading local images, your photo source will probably finish loading before the TTPhotoViewController is registered as a delegate. So, you need to check for delegates added to your TTPhotoSource and send them a modelDidFinishLoad: message if you're done loading when they're added.
And that's easier said than done if you inherit from TTModel, because there's no way to register with an NSMutableArray to find out when it's changed.
So... add the following code to your TTPhotoViewController subclass...
This creates a "virtual" property named superDelegates, which is merely an NSArray, not an NSMutableArray. The insertObject:inSuperDelegatesAtIndex: and removeObjectFromSuperDelegatesAtIndex: methods, because their names include the name of the "superDelegates" property, allow the Key-Value Coding function (which you automatically have because it's an informal protocol) mutableArrayValueForKey: to synthesize a proxy object conforming to NSMutableArray, which allows edits to the superDelegates property by translating mutation operations into calls to the insertObject:inSuperDelegatesAtIndex: and removeObjectFromSuperDelegatesAtIndex: methods.
Then, all you have to do is override the "delegates" method to return such a generated proxy, and poof, all array changes run through you, allowing you to send off the proper load notification when the TTPhotoViewController attaches itself.
经过一番调试,我发现了问题,这只是一个快速修复:
在 Three20UI 项目的 TTModelViewController 类中,找到该方法
并注释 if 条件:
最终将调用
-updateView
方法,而该方法并未调用之前被调用。这是一个快速修复,稍后必须调查 bool:
_isViewAppearing
。After some debugging, I found out the problem, this is just a quick fix:
In TTModelViewController class of Three20UI project, find the method
and comment the if condition:
Eventually
-updateView
method will be called which was not being called previously.This is a quick fix, have to investigate about the bool:
_isViewAppearing
later.