2014-07-02 76 views
0

我是Objective CSwift的新手。在我的示例程序中,我有一個例外'NSInternalInconsistencyException'。我做以下步驟,這是我在斯威夫特第一個程序,我沒有目的C.熟悉Swift中的'NSInternalInconsistencyException'

  1. 創建一個空的應用程序名稱爲SampleTesting
  2. 創建一個CheckingController.xib
  3. 創建一個AppDelegate.swift
  4. 創建一個CheckingController.swift

CheckingController.xib:

我創建了一個Sample Button

AppDelegate.swift:

import UIKit 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 
    var navigationController: UINavigationController? 

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { 
     self.window = UIWindow(frame: UIScreen.mainScreen().bounds) 
     // Override point for customization after application launch. 
     self.window!.backgroundColor = UIColor.whiteColor() 
     self.window!.makeKeyAndVisible() 

     var mainController: CheckingController? = CheckingController(nibName: "CheckingController", bundle: nil) 
     self.navigationController = UINavigationController(rootViewController: mainController) 
     self.window!.rootViewController = self.navigationController 
     return true 
    } 

    func applicationWillResignActive(application: UIApplication) { 

    } 

CheckingController.swift:

import Foundation 
import UIKit 

class CheckingController: UIViewController{ 

    init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) { 
     super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 
    } 

    override func viewDidLoad() { 

     super.viewDidLoad() 
    } 
} 

需要上出了什麼問題怎麼回事,以及如何解決它的一些指導。

謝謝。

回答

0

我也跟着下面的步驟,我固定的錯誤:

  1. 打開XIB文件導致的問題
  2. 點擊文件的所有者圖標左邊欄(頂部一個,看起來像一個黃色輪廓框) 如果您沒有看到右側邊欄,請單擊工具欄中「查看」上方的第三個圖標。這將顯示右側側邊欄
  3. 在右側邊欄中,單擊第三個標籤 - 看起來有點像報紙的標籤
  4. 在頂部的「Custom Class」下,確保Class是應與此視圖相對應的ViewController的名稱。如果沒有,請輸入它在右側邊欄中,點擊最後一個標籤 - 看起來像一個帶箭頭的圓圈的標籤
  5. 您應該在其下看到帶有「view」的「outlets」。在拖動圓圈旁邊的「查看」圖標左邊欄上(下一個,看起來像一個白色方形厚厚的灰色輪廓
  6. 保存XIB並重新運行

Refered here

+0

它很好,你已經找到自己的解決方案 –

+0

@NagaMalleshMaddali感謝您的願望:) :) –

相關問題