PushViewController:HomeButton 无需每次重新加载

发布于 2024-12-20 04:16:40 字数 417 浏览 5 评论 0原文

我的 iPhone 应用程序中的每个视图都有一个自定义 homeButton,并且按照我编写代码的方式,它会重新加载 homeView,其中包含带有所有其他按钮的菜单页面。相反,我观察到当我单击后退按钮(navigationItem)时,它不会重新加载页面。我也想为我的 HomeButton 实现类似的功能,以便我的应用程序更加高效。这是我目前编写的代码。任何人都可以帮我获取 viewController 而不是再次重新加载它。谢谢

 -(void)homButtonClicked{
if(homeView == nil)
    homeView = [[ViewController alloc]init];
[self.navigationController  pushViewController:homeView animated:YES];
  }

I have a custom homeButton in my iphone app on every view and the way I have written code, it reloads the homeView-which has the menu page with all the other buttons. On the contrary, I observe that when I click the back button(navigationItem), it does not reload the page. I would like to implement a similar functionality for my HomeButton too so that my app is much more efficient. This is the code I have written currently. Can anyone help me just fetching the viewController instead of reloading it again. Thanks

 -(void)homButtonClicked{
if(homeView == nil)
    homeView = [[ViewController alloc]init];
[self.navigationController  pushViewController:homeView animated:YES];
  }

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

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

发布评论

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

评论(1

白云不回头 2024-12-27 04:16:40

如果我理解正确,每次单击“主页按钮”时,您都希望加载属于 ViewController 类的 homeView 。为什么不直接加载 ViewController 作为 UINavigationController 的初始视图控制器。每次单击主页按钮时,调用函数 [self.navigationController popToRootViewControllerAnimated:YES]; 哪个将是您的 ViewController 主菜单?

If I understand correctly each time you click on 'home button', you would like to load homeView which is of ViewController class. Why don't you just load the ViewController as the initial view controller of your UINavigationController. And each time you click on the home button, call the function [self.navigationController popToRootViewControllerAnimated:YES]; which will be your ViewController home menu?

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