Three20 的自定义细节图像视图

发布于 2024-12-06 07:30:04 字数 994 浏览 0 评论 0原文

我对 Three20 还很陌生。我遵循了 ray wenderlich 的对 Three20 的介绍以及 Three20 框架中的示例。当我单击缩略图视图(TThumbsViewController 的子类)中的缩略图来启动详细信息视图时,这是一个标准详细信息图像视图(由 TTPhotoViewController 或其超类部署)。我想使用我自己的详细信息视图实现而不是默认的。我在启动TTThumbsViewController子类和TTThumbsViewControllerDelegate方法时放置了以下代码:

- (id)initWithDelegate:(id<TTThumbsViewControllerDelegate>)delegate {
    [super initWithDelegate:delegate];
    return self;
}

- (void)thumbsViewController: (TTThumbsViewController*)controller 
              didSelectPhoto: (id<TTPhoto>)photo {
    [navigationController.pushViewController:photoDetailViewController 
                                    animated:Yes];
}

但默认的TTPhotoViewController视图仍然占主导地位。当我将 NSLog 放入委托方法中时。我可以看到该方法被调用。我认为有人已经在 TTThumViewController 中设置了另一个委托?有人可以推荐一种显示我的详细照片视图的方法吗?我可以使用另一个拇指视图控制器吗?任何建议将不胜感激。

I am pretty new with Three20. I have followed ray wenderlich's nice introduction to three20 and the examples within the three20 framework. When I click on a thumbnail in a thumbnail view (subclass of TTThumbsViewController) to launch a Details view, a standard Details image view (deployed by TTPhotoViewController or its super class). I would like to use my own implementation of a Details View instead of the default. I put the following code when I initiated the subclass of TTThumbsViewController and TTThumbsViewControllerDelegate method:

- (id)initWithDelegate:(id<TTThumbsViewControllerDelegate>)delegate {
    [super initWithDelegate:delegate];
    return self;
}

- (void)thumbsViewController: (TTThumbsViewController*)controller 
              didSelectPhoto: (id<TTPhoto>)photo {
    [navigationController.pushViewController:photoDetailViewController 
                                    animated:Yes];
}

But the default TTPhotoViewController view still prevail. When I put a NSLog in the delegate method. I coud see the method was called. I think there is another delegate someone already set in TTThumViewController? Can someone recommend a way to display my detail photo view? Is there another thumbs view controller I can use? Any suggestion will be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

陌上芳菲 2024-12-13 07:30:04

我对所有这些(编码等)都很陌生,但我会分享我发现的内容。通过查找 ttthumbsviewcontroller 的定义,我找到了以下方法(术语错误?):-

- (void)thumbsTableViewCell:(TTThumbsTableViewCell*)cell didSelectPhoto:(id<TTPhoto>)photo {
  [_delegate thumbsViewController:self didSelectPhoto:photo];

  BOOL shouldNavigate = YES;
  if ([_delegate respondsToSelector:@selector(thumbsViewController:shouldNavigateToPhoto:)]) {
    shouldNavigate = [_delegate thumbsViewController:self shouldNavigateToPhoto:photo];
  }

  if (shouldNavigate) {
    NSString* URL = [self URLForPhoto:photo];
    if (URL) {
      TTOpenURLFromView(URL, self.view);

    } else {
      TTPhotoViewController* controller = [self createPhotoViewController];
      controller.centerPhoto = photo;
      [self.navigationController pushViewController:controller animated:YES];
    }
  }
}

在 else 语句中,我发现这调用了 photoviewcontroller 的创建。通过在我自己的代码的实际主体中调用此方法(?)并更改 else 语句中的主体,我能够添加自定义详细信息视图。进一步深入 ttthumbsnailviewcontroller 的定义,您可以发现 creatPhotoViewController 调用 PhotoViewController 的启动,因此在代码主体中调用该方法(?)并初始化另一个视图也是可行的。

如果有人可以解释这是否是一个好的方法(我有一种感觉不是),我们将不胜感激。另外,为什么将方法放在代码主体中会覆盖那里的调用。

I'm really new to all of this (coding, etc.) but I'll share what I've found. By looking up the definition of ttthumbsviewcontroller, I was able to find the following method(wrong term?):-

- (void)thumbsTableViewCell:(TTThumbsTableViewCell*)cell didSelectPhoto:(id<TTPhoto>)photo {
  [_delegate thumbsViewController:self didSelectPhoto:photo];

  BOOL shouldNavigate = YES;
  if ([_delegate respondsToSelector:@selector(thumbsViewController:shouldNavigateToPhoto:)]) {
    shouldNavigate = [_delegate thumbsViewController:self shouldNavigateToPhoto:photo];
  }

  if (shouldNavigate) {
    NSString* URL = [self URLForPhoto:photo];
    if (URL) {
      TTOpenURLFromView(URL, self.view);

    } else {
      TTPhotoViewController* controller = [self createPhotoViewController];
      controller.centerPhoto = photo;
      [self.navigationController pushViewController:controller animated:YES];
    }
  }
}

In the else statement, I've found this calls the creation of the photoviewcontroller. By recalling this method (?) in the actual body of my own code and changing the body in the else statement I was able to add a custom detail view. Further down the definition of the ttthumbsnailviewcontroller, you can find that the creatPhotoViewController calls for an initiation of the PhotoViewController so calling that method(?) in the body of the code and initializing another view also works.

If someone can explain whether or not this is a good method of doing this (I have a feeling that is not), it would be appreciated. Also why does putting the method in the body of the code override the call there.

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