如何弹出 TTPhotoViewController?

发布于 2024-09-10 06:28:03 字数 1463 浏览 2 评论 0原文

我一直试图从 Three20 中弹出 TTPhotoViewController。起初它没有后退按钮,但我现在已经实现了它并尝试弹出视图,但没有成功。这是我的代码片段:

Button (这有效) --

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:TTLocalizedString(@"Back", @"Back to Albums") style:UIBarButtonItemStyleBordered target:self action:@selector(popView)];

-popView (方法被调用,但语句不起作用) --

- (void) popView {
    [self.navigationController popViewControllerAnimated:NO]; 
}

谢谢

UPDATE 0 -

这是 ttphotoviewcontroller 在其 init 中的代码(我检查了该程序是运行这个)——

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
      self.navigationItem.backBarButtonItem =
      [[[UIBarButtonItem alloc]
      initWithTitle:
      TTLocalizedString(@"Photo",
         @"Title for back button that returns to photo browser")
      style: UIBarButtonItemStylePlain
      target: nil
      action: nil] autorelease];

      self.statusBarStyle = UIStatusBarStyleBlackTranslucent;
      self.navigationBarStyle = UIBarStyleBlackTranslucent;
      self.navigationBarTintColor = nil;
      self.wantsFullScreenLayout = YES;
      self.hidesBottomBarWhenPushed = YES;

      self.defaultImage = TTIMAGE(@"bundle://Three20.bundle/images/photoDefault.png");
  }

return self;
}

它已经添加了一个后退按钮,但可惜的是,这段代码也没有向我的导航栏添加按钮。

I'm stuck trying to pop a TTPhotoViewController from three20. At first it did not come with a back button, but I have now implemented it and tried to pop the view with no luck. Here's a snippet of my code:

Button (this works) --

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:TTLocalizedString(@"Back", @"Back to Albums") style:UIBarButtonItemStyleBordered target:self action:@selector(popView)];

-popView (method is called, but statement does NOT work) --

- (void) popView {
    [self.navigationController popViewControllerAnimated:NO]; 
}

thanks

UPDATE 0 -

This is the code that ttphotoviewcontroller had in its init (I checked that the program was running this) --

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
      self.navigationItem.backBarButtonItem =
      [[[UIBarButtonItem alloc]
      initWithTitle:
      TTLocalizedString(@"Photo",
         @"Title for back button that returns to photo browser")
      style: UIBarButtonItemStylePlain
      target: nil
      action: nil] autorelease];

      self.statusBarStyle = UIStatusBarStyleBlackTranslucent;
      self.navigationBarStyle = UIBarStyleBlackTranslucent;
      self.navigationBarTintColor = nil;
      self.wantsFullScreenLayout = YES;
      self.hidesBottomBarWhenPushed = YES;

      self.defaultImage = TTIMAGE(@"bundle://Three20.bundle/images/photoDefault.png");
  }

return self;
}

It was already adding a back button, but alas this code also doesn't add a button to my navbar.

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

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

发布评论

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

评论(2

月下客 2024-09-17 06:28:03

如果您正在做的事情与他在 Catalog 示例中所做的类似,那么您只需将其添加到根视图控制器中(即不在被推入堆栈后出现的视图中,但是在父视图中)。

此操作与常规 iPhone UINavigationController 操作没有什么不同。

- (id)init {
    if (self = [super init]) {

    // setup back button for nav controller
    self.navigationItem.backBarButtonItem =
      [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered
      target:nil action:nil] autorelease];

    }
}

当新视图被推入堆栈时,它将使用后退按钮返回。您不必调用 popView 或其他任何东西。请注意,我使用的是 backBarButtonItem,而您使用的是 leftBarButtonItem(仅当您使用自定义后退按钮时才使用)。

有关更多信息,请阅读 本文档

If you are doing something similar to what he did in the Catalog example, then you just add this in the root view controller (i.e. NOT in the view that will appear after it gets pushed onto the stack, but in the parent view).

This action is no different from regular iPhone UINavigationController actions.

- (id)init {
    if (self = [super init]) {

    // setup back button for nav controller
    self.navigationItem.backBarButtonItem =
      [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered
      target:nil action:nil] autorelease];

    }
}

When the new view gets pushed onto the stack, it will use that back button to return. You shouldn't have to call popView or anything else. Notice I am using backBarButtonItem whereas you are using leftBarButtonItem (which you only use if you are using a custom back button).

For more information, read the "Updating the Navigation Bar" section of this document

我还不会笑 2024-09-17 06:28:03

在推送 TTPhotoViewController 之前添加此代码。

    UIBarButtonItem *backButton=[[[UIBarButtonItem alloc] initWithTitle:@"ButtonTitle"                 
                                                                  style:UIBarButtonItemStyleBordered
                                                                 target:nil
                                                                action:nil] autorelease];

    self.navigationItem.backBarButtonItem = nil;
    self.navigationItem.backBarButtonItem = backButton;

Before you push the TTPhotoViewController add this code.

    UIBarButtonItem *backButton=[[[UIBarButtonItem alloc] initWithTitle:@"ButtonTitle"                 
                                                                  style:UIBarButtonItemStyleBordered
                                                                 target:nil
                                                                action:nil] autorelease];

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