如何移动 UIViewController?

发布于 2024-12-28 13:28:24 字数 215 浏览 1 评论 0原文

我想做一个像 Facebook 这样的应用程序,当你按下面板按钮时,菜单会出现在左侧。为此,我有一个带有 UITableView 的第一个 UIViewController,另一个放在上面的带有没有动画的模式转换的 UIViewController。为了显示 UITableView (我的菜单),我想将第二个 UIViewController 移动到右侧。

我怎样才能做到这一点?这是正确的方法吗?

I want to do an app like Facebook with the menu that appears on the left when you push on the panel button. To do that, I have a first UIViewController with an UITableView, and another put above with a modal transition without animation. To display the UITableView (my menu), I want to move my second UIViewController on the right.

How can I do that ? It is the right way ?

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

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

发布评论

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

评论(2

以为你会在 2025-01-04 13:28:24

我怎样才能做到这一点?

只是使用 UIView 动画来移动视图控制器的视图。添加另一个视图(即菜单),并使用相同的动画移动它。这实际上很容易。

[UIView animateWithDuration:.5 animations:^{
    [menu setFrame:CGRectOffset([menu frame], [menu frame].size.width, 0)];
    [mainView setFrame:CGRectOffset([mainView frame], [menu frame].size.width, 0)];
}];

这是正确的方法吗?

我不知道你所说的“正确的方式”是什么意思……也许吧?

How can I do that ?

Just used a UIView animation to move the view of the view controller. Add another view that is your menu, and move that using the same animation. It's actually pretty easy.

[UIView animateWithDuration:.5 animations:^{
    [menu setFrame:CGRectOffset([menu frame], [menu frame].size.width, 0)];
    [mainView setFrame:CGRectOffset([mainView frame], [menu frame].size.width, 0)];
}];

It is the right way ?

I don't know what you mean by "the right way"... Sooooo, maybe?

姐不稀罕 2025-01-04 13:28:24

您需要的内容以模板形式提供。
检查这个 git..下载它..并使用它..

https://github.com/pkluz/ZUUIRevealController

What you need is provided as a template.
Check this git..download it..and play around with it..

https://github.com/pkluz/ZUUIRevealController

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