如何弹出 TTPhotoViewController?
我一直试图从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在做的事情与他在
Catalog
示例中所做的类似,那么您只需将其添加到根视图控制器中(即不在被推入堆栈后出现的视图中,但是在父视图中)。此操作与常规 iPhone UINavigationController 操作没有什么不同。
当新视图被推入堆栈时,它将使用后退按钮返回。您不必调用 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.
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 usingleftBarButtonItem
(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
在推送 TTPhotoViewController 之前添加此代码。
Before you push the TTPhotoViewController add this code.