2016-01-20 53 views
0

我已经开发了一个应用,该应用的工作相当不错,在iOS版9,但如果我打开一个控制器,一个静态的UITableViewCell有这样的错误:layoutMarginsFollowReadableWidth错误的iOS 8

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

我检查,如果有一个'空'的连接,但没有。

这是视图控制器的代码:

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(["[email protected]"]) 

     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!) 
    } 

} 

我希望你们中有些人是什么原因造成这个错误的想法。

回答

1

我也在Xcode项目中遇到过这个问题,最后解决了它。 错误是:“终止应用程序由于未捕获的异常‘NSUnknownKeyException’,原因:‘[setValue方法:forUndefinedKey:]:这个类不是密钥值编码兼容的关键layoutMarginsFollowReadableWidth’。”

其原因是我在大小检查器选项中使用“添加大小类定制”,将其删除并再次运行,错误消失。希望对你有帮助。 As is shown in picture