gpt4 book ai didi

没有 uinavigationcontroller 的 iPhone 导航模型?

转载 作者:行者123 更新时间:2023-12-03 21:11:37 25 4
gpt4 key购买 nike

我正在编写一个应用程序,需要显示一系列大约 10-20 个“ View ”。我有 4 个 View Controller 和 Nib ,我想使用。每个 View 上都有一个前进和后退按钮, View 应根据按下的按钮从右侧或左侧滑入。我希望能够重用 Nib 和 Controller 来呈现信息。我试图使用 uinavigation Controller ,但遇到了无法将 View 多次推送到堆栈的问题。整体结构是一个 tabbarcontroller 内的 unavigationcontroller。有没有办法使用 uinavigation Controller 来做到这一点,或者我应该尝试不同的方法。

最佳答案

我建议制作一个容器 View Controller 类。它将创建并“拥有”您想要使用的四个不同的 View Controller 。然后使用类似这样的东西在它们之间切换:

// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view view
UIView *theWindow = [currentView superview];

// remove the current view and replace with newView
[currentView removeFromSuperview];
[theWindow addSubview:newView];

// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];

(盗自 here )

关于没有 uinavigationcontroller 的 iPhone 导航模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2875899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com