iOS 8 中的 layoutMarginsFollowReadableWidth 错误

layoutMarginsFollowReadableWidth error in iOS 8

我开发了一个在 iOS9 中运行良好的应用程序,但是如果我打开一个带有静态 UITableViewCell 的控制器,则会出现此错误:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key layoutMarginsFollowReadableWidth.'

我检查了是否有 'empty' 连接,但没有。

这是ViewController的代码:

class KontaktController: UITableViewController, MFMailComposeViewControllerDelegate{

    @IBOutlet weak var mapView: MKMapView!
    @IBOutlet weak var openMenu: UIBarButtonItem!

    let mailController = MFMailComposeViewController()

    override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        switch UIDevice.currentDevice().userInterfaceIdiom {
        case .Phone:
            // It's an iPhone
            switch indexPath.section{
            case 0:
                return 150
            case 3:
                if indexPath.row == 0{
                    return 150
                }
                else{
                    return 100
                }
            default:
                return 53
            }
        case .Pad:
            // It's an iPad
            switch indexPath.section{
            case 0:
                return 250
            case 3:
                if indexPath.row == 0{
                    return 250
                }
                else{
                    return 100
                }
            default:
                return 53
            }
        default:
            print("OH ?!")
            // Uh, oh! What could it be?
        }

      return 10
    }


    @IBAction func kontaktirenSieUnsPressed(sender: AnyObject) {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let user = PFUser.currentUser()
        if user != nil{
            if user?.username != nil {

                let viewController: UINavigationController = storyboard.instantiateViewControllerWithIdentifier("anfrage_Navigation") as! UINavigationController
                let addVC =  storyboard.instantiateViewControllerWithIdentifier("neue_anfrage") as! AddAnfrageController



                revealViewController().pushFrontViewController(viewController, animated: true)
                viewController.pushViewController(addVC, animated: true)
                return
                //rootViewController.pushViewController(viewController, animated: true)
            }
        }

        let logInViewController = storyboard.instantiateViewControllerWithIdentifier("LogIn")
        self.presentViewController(logInViewController, animated: false, completion: nil)
    }
    @IBAction func adressPressed(sender: UIButton) {

        switch sender.tag{
        case 0:
            let url: NSURL = NSURL(string: "tel://004965185730")!
            UIApplication.sharedApplication().openURL(url)
        case 2:
            let mailComposeViewController = configuredMailComposeViewController()
            if MFMailComposeViewController.canSendMail() {
                self.presentViewController(mailComposeViewController, animated: true, completion: nil)
            } else {
                self.showSendMailErrorAlert()
            }
        case 3:
            let url: NSURL = NSURL(string: "http://www.dachdecker-kremer.de")!
            UIApplication.sharedApplication().openURL(url)
        default:
            print("")
        }
    }

    override func viewDidLoad() {
        // SWReveal Button:
        // Menu öffnen
        openMenu.target = self.revealViewController()
        openMenu.action = Selector("revealToggle:")
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

        let regionRadius: CLLocationDistance = 500
        let location = CLLocation(latitude: 49.743056, longitude:  6.621047)
        let region = MKCoordinateRegionMakeWithDistance(location.coordinate,
            regionRadius * 2.0, regionRadius * 2.0)
        mapView.setRegion(region, animated: false)

        // Banner:
        let anotation = MKPointAnnotation()
        anotation.coordinate = CLLocationCoordinate2D(latitude: 49.743056, longitude: 6.621047)
        anotation.title = "Dachdecker Kremer"
        mapView.addAnnotation(anotation)

    }



    // Send email:
    func configuredMailComposeViewController() -> MFMailComposeViewController {
        let mailComposerVC = MFMailComposeViewController()
        mailComposerVC.mailComposeDelegate = self // Extremely important to set the --mailComposeDelegate-- property, NOT the --delegate-- property

        mailComposerVC.setToRecipients(["info@dachdecker-kremer.de"])

        mailComposerVC.setMessageBody("Gesendet von der Dachdecker Kremer App.", isHTML: false)

        return mailComposerVC
    }

    func showSendMailErrorAlert() {
        let sendMailErrorAlert = UIAlertController(title: "E-mail senden fehlgeschlagen", message: "Ihr iPhone kann leider keine Mails senden. Gehen Sie zu Einstellungen/Mail, um den Fehler zu beheben.", preferredStyle: .Alert)
        sendMailErrorAlert.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: nil))
        self.presentViewController(sendMailErrorAlert, animated: true, completion: nil)
    }

    // MARK: MFMailComposeViewControllerDelegate Method
    func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
        controller.dismissViewControllerAnimated(true, completion: nil)
    }
    @IBAction func route(sender: AnyObject) {
        let targetURL = NSURL(string: "http://maps.apple.com/?daddr=49.743056,6.621047&dirflg=d&t=h")
        UIApplication.sharedApplication().openURL(targetURL!)
    }

}

我希望你们中的一些人知道是什么导致了这个错误。

我在Xcode项目中也遇到过这个问题,最后解决了。 错误是:"Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key layoutMarginsFollowReadableWidth.'"

原因是我在尺寸检查器选项中使用了 "Add Size Class Customization",删除它并再次 运行,错误消失了。希望对你有帮助。 As is shown in picture