Tag: uipageviewcontroller

Swiftdynamic投射UIPageViewController失败

我试图把我的window.rootViewController作为一个UIPageViewController,但任何时候我访问我定义它的类属性炸毁与swift dynamic cast failed 。 我的故事板有一个UIPageViewController是最初的场景。 PageViewController只是UIPageViewController的一个子类 class AppDelegate: UIResponder, UIApplicationDelegate, UIPageViewControllerDataSource { var window: UIWindow! var pageViewController: PageViewController { return window.rootViewController as PageViewController } func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { pageViewController.dataSource = self return true } }

刷UIPageViewController – Swift上出现的差距

我用UIPageViewController创build了一个“模块屏幕”的容器。 如果设置前一个屏幕,主要问题是大小错误。 在屏幕截图上,你可以看到显示2个屏幕,而不是1。 用于设置我使用的新屏幕 func launchViewControllerC(vc: USBaseVaultStepViewcontroller, step: UIPageViewControllerNavigationDirection, animated: Bool = true) { vc.delegate = self self.pageController.setViewControllers([vc], direction: step, animated: true, completion: nil) } 对于之前的屏幕我使用: func launchPreviousScreen() { guard let previousStep = self.currentSetupStep.previousStep() else { return } guard let previousController = self.setupStepViewControllerForStep(previousStep) else { return } self.currentSetupStep = previousStep previousController.delegate = self self.pageController.setViewControllers([previousController], direction: […]

嵌套的UIPageViewcontroller转换

我正在与UIPageViewController和我想要的是嵌套的UIPageViewControllers。 这是我想要实现的解释: 有两个UIPageViewController:1. BasePageController 2. SecondPageController 在SecondPageController中,有2个子viewController:ViewController1&ViewController2。 这里是BasePageController的代码: class BasePageController: UIPageViewController { lazy var orderedViewControllers: [UIViewController] = { return [self.newVc(identifier: "SecondPageController"), self.newVc(identifier: “ViewController3”)] }() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.delegate = self self.dataSource = self if let firstViewController = orderedViewControllers.first { setViewControllers([firstViewController], direction: .forward, animated: true, […]

将数据从embedded的PageViewController传递给父视图控制器

我正在开发一个包含“代表查找器”的应用程序,该应用程序允许某人在UITextField中input他们的地址,或者从PickerView中select一个状态来查看其政府代表。 我有一个主要的ViewController,将显示用户提交上述选项之一后的结果。 在此基础上,我实施了一个ContainerView,其中embedded了两个页面的PageViewController; 一个包含一个UITextField和button来按地址进行search,另一个包括一个PickerView和一个按状态search的button。 PageView当前通过embedded转换连接到TableView,但是,当我尝试在PageViewController中引用父表视图控制器时,它说PVC没有父对象,即使ViewController将PageViewController标识为它的子对象。 我的问题是:什么是正确的方式来传递variables从一个孩子PageViewController到它的容器? 编辑:我已经尝试了以下,但它不起作用: 在我的PageViewController中: protocol SearchFinderDelegate: class { func getResults(results: String) } class LawSearchWindow: UIPageViewController { weak var newDelegate: SearchFinderDelegate? viewDidLoad() { /*Attempt to initialize newDelegate*/ newDelegate=self newDelegate?.getResults(results: “test123”) }} 在我的主要VC课程中,我有: func getResults(results: String) { print(results) } 更新:当我尝试做'newDelegate =自我'的声明,它告诉我'不能分配'VC名称'types的值键入'委托名称'

iOS – 这个UIPageViewController由UISegmentedControl控制,或者这是什么?

这个UIPageViewController如何被这个头部控制好像是UISegmentedControl ?

一个UIScrollView在UIPageViewController里滚动了多less?

我想弄清楚我的UIPageViewController里面的滚动视图有多less滚动。 我在viewLoad中从UIPageViewController访问UIScrollView有以下代码。 for (UIView *view in self.pageViewController.view.subviews) { if ([view isKindOfClass:[UIScrollView class]]) { thisControl = (UIScrollView *)view; } } 所以一旦我有了UIScrollView,调用了这个控件,我想通过做这样的事情打印多less已经滚动: NSLog (@"Scroll: %f",thisControl.contentOffset.x); 问题是,我真的不知道该把这条线放在哪里,或者如何连续打印已经滚动了多less。 任何想法?

刷新一个UIPageViewController

我有一个pipe理3 UIViewController的UIPageViewController ( <UIPageViewControllerDataSource>委托)。 从第二个视图到第三个视图,我必须点击一个button,否则第二个视图是最后一个可见页面。 一旦在第3页,用户应该能够滑动回到2,但不能滑动回到3(button总是需要到第3页)。 这是代码的一部分: – (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController { UIViewController *prevViewController = nil; if (viewController == self.P2ViewController) { prevViewController = self.P1ViewController; } if (viewController == self.P3ViewController) { [self pageViewController:pageViewController viewControllerAfterViewController:self.P2ViewController]; /*this doesn't work*/ prevViewController = self.P2ViewController; } return prevViewController; } – (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { UIViewController *nextViewController = […]

防止UIPageViewController的滑动影响UISlider

我在其他方面看过这个问题,但没有一个答案适用于我的情况。 我有一个UIPageViewController有一个包含UISlider的子视图控制器。 当您尝试移动滑块时,它会激活页面视图控制器的滚动。 您必须点击,在滑块圆上暂停,然后移动。 UIPageViewController设置为滚动types,因此未设置gestureRecognizers。 (标头状态“只有过渡样式是'UIPageViewControllerTransitionStylePageCurl')填充。 因此,我甚至无法正确访问手势。 我已经尝试了几件事情,以防止UIPageViewController影响滑块,但无济于事。 我试过了:1)走子子树,并设置UIScrollView的平移手势委托给自己(这会导致崩溃)2)在顶部添加我自己的手势,并检查y值。 这将防止滑动,但它也吃龙头和移动,所以滑块实际上并没有如预期的那样改变3)实现了自定义滑块的自定义手势。 问题是我无法匹配的平移手势改变滑块在相同的默认值。 既然你必须实现平移,并自己调整位置,那么很难匹配真实的行为。 这些方法都不适用于我。 有没有人能够解决这个问题? 我能想到的唯一解决scheme是防止一起滚动,添加左/右button,并相应地编程转换页面。

从数组的UIImage名称不断返回零值。

在容器中设置页面视图。 遵循我可以find的所有说明(初学者)。 这两个数组在主视图控制器中,它们具有我要填充页面的图像的名称。 self.shirtImage = NSArray(objects: "shirt1", "shirt2") self.pantsImage = NSArray(objects: "pants1", "pants2") 每当我运行程序,这两行: self.todayShirt.image = UIImage(named: self.shirtName) self.todayPants.image = UIImage(named: self.pantsName) 返回错误fatal error: unexpectedly found nil while unwrapping an Optional value或CUICatalog: Invalid asset name supplied:这意味着他们从数组中收到一个零值。 页面内容类看起来像这样: class TodayPicksViewController: UIViewController { @IBOutlet weak var todayShirt: UIImageView! @IBOutlet weak var todayPants: UIImageView! var pageIndex: Int! var […]

如何导航回到已删除的PageViewController条目/更改PageViewController条目

情况:我想从一个数据条目列表导航到我的PageViewController。 之前和之前的function工作 func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? { if ((viewController as! LocationViewController).mLocationIndex > 0){ let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewControllerWithIdentifier("LocationViewController") as! LocationViewController vc.mLocationIndex = (viewController as! LocationViewController).mLocationIndex – 1 return vc } return nil } func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? { let locCount = […]