我有一個UIPageViewController
與三個嵌入UINavigationController
s。該應用在我的設備上完美運行,但在其他一些測試設備上,我收到Crashlytics的崩潰:function signature specialization <Arg[0] = Owned To Guaranteed>
。功能簽名專業化<Arg [0] =擁有保證>
這是我在Crashlytics收到的報告。
這是我使用的設置我的UIPageViewController
代碼。
import Foundation
import UIKit
import Parse
class PageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
private var pages: [UINavigationController]!
private var currentPageIndex: Int!
override func viewDidAppear(animated: Bool) {
if (FBSDKAccessToken.currentAccessToken() != nil) {
} else {
self.performSegueWithIdentifier("toSignup", sender: self)
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Page view controller is initial VC, but if FB Access Token is nil, redirect to signup flow
if (FBSDKAccessToken.currentAccessToken() != nil) {
self.dataSource = self
self.delegate = self
self.pages = [
self.storyboard!.instantiateViewControllerWithIdentifier("DiscoverNav") as! UINavigationController,
self.storyboard!.instantiateViewControllerWithIdentifier("LiveFeedNav") as! UINavigationController,
self.storyboard!.instantiateViewControllerWithIdentifier("ProfileNav") as! UINavigationController
]
(self.pages[0].topViewController as! DiscoverViewController).parentPageViewController = self
(self.pages[1].topViewController as! LiveFeedViewController).parentPageViewController = self
(self.pages[2].topViewController as! ProfileViewController).parentPageViewController = self
self.currentPageIndex = 1
let startingViewController = self.pages[1] as UINavigationController
self.setViewControllers([startingViewController], direction: .Forward, animated: false, completion: nil)
} else {
self.performSegueWithIdentifier("toSignup", sender: self)
}
}
func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? {
let index = (self.pages as NSArray).indexOfObject(viewController)
self.currentPageIndex = index
// if currently displaying last view controller, return nil to indicate that there is no next view controller
return (self.currentPageIndex == self.pages.count - 1 ? nil : self.pages[self.currentPageIndex + 1])
}
func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? {
let index = (self.pages as NSArray).indexOfObject(viewController)
self.currentPageIndex = index
// if currently displaying first view controller, return nil to indicate that there is no previous view controller
return (index == 0 ? nil : self.pages[index - 1])
}
func displayPageForIndex(index: Int, animated: Bool = true) {
assert(index >= 0 && index < self.pages.count, "Error: Attempting to display a page for an out of bounds index")
// nop if index == self.currentPageIndex
if self.currentPageIndex == index { return }
if index < self.currentPageIndex {
self.setViewControllers([self.pages[index]], direction: .Reverse, animated: true, completion: nil)
} else if index > self.currentPageIndex {
self.setViewControllers([self.pages[index]], direction: .Forward, animated: true, completion: nil)
}
self.currentPageIndex = index
}
}
現在看來,如果崩潰是從ProfileViewController.swift
到來,但從來都沒有得到該網頁上UIPageView
加載時調用。在Crashlytics報告的第16行中,它指向PageViewController。似乎沒有關於這個錯誤的很多信息,但從我讀過的內容來看,它似乎與某個地方的零值有關。任何人都可以就此提供建議嗎?
和線路47上PageViewController點self.storyboard!.instantiateViewControllerWithIdentifier("ProfileNav") as! UINavigationController
您是否嘗試過不打開這些選項? 'self.storyboard?.instantiateViewControllerWithIdentifier(「ProfileNav」)爲? UINavigationController' –