TTPhotoViewController:滑动之前图像不会加载

发布于 2024-09-05 06:07:33 字数 701 浏览 7 评论 0原文

我正在尝试在示例 iPad 应用程序中实现 TTPhotoViewController 。我已经正确实现了 TTPhotoSourceTTPhoto 协议。 TTPhotoViewController 确实显示图像,但只有在滑动时才会显示图像。

下面标签栏中的左右按钮似乎根本不起作用,它们永远不会改变显示的图像。当到达最后一个或第一个图像时,UIActivityIndi​​catorView 永远不会被放置,左右按钮也不会被验证。

我正在将 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 技术交流群。

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

发布评论

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

评论(3

挽袖吟 2024-09-12 06:07:33

您很可能重写了 TTPhotoViewController 子类中的 viewWillAppear 方法,但忘记调用 super 方法。

You have most likely overriden the viewWillAppear method in your TTPhotoViewController subclass but forgot to call the super method.

我还不会笑 2024-09-12 06:07:33

有同样的问题。 TTPhotoSource 完成加载后需要将 modelDidFinishLoad: 发送给其委托...否则,TTPhotoViewController 会认为它尚未准备好。

然而,这还不是全部。特别是在加载本地图像时,您的照片源可能会在 TTPhotoViewController 注册为委托之前完成加载。因此,您需要检查添加到 TTPhotoSource 的委托,如果在添加委托时加载完毕,则向它们发送 modelDidFinishLoad: 消息。

如果您继承自 TTModel,那么说起来容易做起来难,因为没有办法注册 NSMutableArray 来找出它何时发生更改。

所以...将以下代码添加到您的 TTPhotoViewController 子类中...

// superDelegates KVO Mutator Methods

- (NSMutableArray*)delegates {
 return [self mutableArrayValueForKey:@"superDelegates"];
}

- (void)insertObject:(id)object inSuperDelegatesAtIndex:(NSUInteger)index {
 [super.delegates insertObject:object atIndex:index];

 if ([self isLoaded]) {
  if ([object respondsToSelector:@selector(modelDidFinishLoad:)]) {
   [object performSelector:@selector(modelDidFinishLoad:) withObject:self];
  }
 }
}

- (void)removeObjectFromSuperDelegatesAtIndex:(NSUInteger)index {
    [super.delegates removeObjectAtIndex:index];
}

- (NSArray*) superDelegates {
 return super.delegates;
}

这将创建一个名为 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...

// superDelegates KVO Mutator Methods

- (NSMutableArray*)delegates {
 return [self mutableArrayValueForKey:@"superDelegates"];
}

- (void)insertObject:(id)object inSuperDelegatesAtIndex:(NSUInteger)index {
 [super.delegates insertObject:object atIndex:index];

 if ([self isLoaded]) {
  if ([object respondsToSelector:@selector(modelDidFinishLoad:)]) {
   [object performSelector:@selector(modelDidFinishLoad:) withObject:self];
  }
 }
}

- (void)removeObjectFromSuperDelegatesAtIndex:(NSUInteger)index {
    [super.delegates removeObjectAtIndex:index];
}

- (NSArray*) superDelegates {
 return super.delegates;
}

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.

北城半夏 2024-09-12 06:07:33

经过一番调试,我发现了问题,这只是一个快速修复:

在 Three20UI 项目的 TTModelViewController 类中,找到该方法

-refresh

并注释 if 条件:

if (_isViewAppearing)

最终将调用 -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

-refresh

and comment the if condition:

if (_isViewAppearing)

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.

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