将导航栏滑开,就像 iPhone 的照片查看器一样

发布于 2024-10-10 04:05:19 字数 114 浏览 6 评论 0原文

有人可以解释一下,如何在 tableviewcontroller 中滑动导航栏,就像 iphone 照片查看器的导航栏一样吗?

如果有人能给我一些代码,那就太好了。

感谢和问候 马可

does anybody could please explain me, how to slide away the navigation bar in a tableviewcontroller, like the navigation bar of the iphone photo viewer?

It would be great, if anybody has some code for me.

Thanks and regards
Marco

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

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

发布评论

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

评论(1

睫毛溺水了 2024-10-17 04:05:19

您需要使用 UINavigationController,然后此功能几乎是“免费”的。
在创建阶段,您首先创建视图控制器。然后创建一个 UINavigationController,并将其传递给您之前创建的视图控制器。
稍后,当您想要滑开导航栏时,您可以使用 pushViewController:animated: 函数调用推送一个新的视图控制器。看一下下面的代码:

// Creation time
// Create your own view controller. below is just an example
UIViewController *myController = [[UIViewController alloc] init];

// Now create a navigation controller
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myController];

// Retain the above somehow, add their view to the Window etc. - not detailed here

// Later, when you want to slide away your controller, you need to push a new view controller. 
// The below code assumes "self" is actually myController which you defined previously:

UIViewController *newController = [[UIViewController alloc] init];
[self.navigationController pushViewController:newController animated:YES];
// The above line will make the controller and navigation bar slide away, revealing your new controller

这是一个非常粗略的代码示例,其中不包括内存管理等所有细节。我希望这就是您正在寻找的内容。

You need to use a UINavigationController, and then this functionality comes almost "for free".
At creation stage, you first create your view controller. Then you create a UINavigationController, passing it your previously created view controller.
Later on, when you want to slide away the navigation bar, you push a new view controller using the pushViewController:animated: function call. Take a look at the code below:

// Creation time
// Create your own view controller. below is just an example
UIViewController *myController = [[UIViewController alloc] init];

// Now create a navigation controller
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myController];

// Retain the above somehow, add their view to the Window etc. - not detailed here

// Later, when you want to slide away your controller, you need to push a new view controller. 
// The below code assumes "self" is actually myController which you defined previously:

UIViewController *newController = [[UIViewController alloc] init];
[self.navigationController pushViewController:newController animated:YES];
// The above line will make the controller and navigation bar slide away, revealing your new controller

This is a very rough code sample, which does not include all the details such as memory management etc. I hope this is what you were looking for.

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