简体   繁体   English

如何弹出TTPhotoViewController?

[英]How do I pop a TTPhotoViewController?

I'm stuck trying to pop a TTPhotoViewController from three20. 我被困试图从three20弹出TTPhotoViewController。 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) -- -popView(方法已调用,但语句不起作用)-

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

thanks 谢谢

UPDATE 0 - 更新0-

This is the code that ttphotoviewcontroller had in its init (I checked that the program was running this) -- 这是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;
}

It was already adding a back button, but alas this code also doesn't add a button to my navbar. 它已经在添加后退按钮,但是可惜这段代码也没有在我的导航栏中添加按钮。

If you are doing something similar to what he did in the Catalog example, then you just add this in the root view controller (ie NOT in the view that will appear after it gets pushed onto the stack, but in the parent view). 如果您执行的操作与他在Catalog示例中的操作类似,则只需将其添加到根视图控制器中(即,不在将其推入堆栈后出现的视图中,而是在父视图中)。

This action is no different from regular iPhone UINavigationController actions. 此操作与常规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];

    }
}

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. 您不必调用popView或其他任何东西。 Notice I am using backBarButtonItem whereas you are using leftBarButtonItem (which you only use if you are using a custom back button). 请注意,我使用的是backBarButtonItem而您使用的是leftBarButtonItem (仅在使用自定义后退按钮时才使用)。

For more information, read the "Updating the Navigation Bar" section of this document 有关更多信息,请阅读本文档的“更新导航栏”部分。

Before you push the TTPhotoViewController add this code. 在您推送TTPhotoViewController之前,请添加以下代码。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM