2015-11-27 12 views
1

我不斷收到一個setValue:forUndefinedKey:]:這個類不是關鍵值,它是關鍵dummyTextField的編碼兼容。在XIB中將UIView的UITextField加載到ViewCrontroller中,並在故事板中顯示視圖

編輯:我需要連接UIView(nib文件)中的UITextField到ViewController。 UIView作爲ViewController中的子視圖加載。一旦按下按鈕,我需要UITextField的內容

請下載以下文件並嘗試使用。如果你能幫助我,這將是非常感謝。

https://drive.google.com/file/d/0B_Z-8IMBX2LcSURBRktzZ2tzWWc/view?usp=sharing

請注意,我已經成功的按鈕,在控制器工作,錯誤僅僅是與文本框的IBOutlet中。

如果你能想出另外一種方法來完成這個任務(比如使用委託方法),那麼我就是耳熟能詳。

謝謝

P.S.我做了谷歌它,並遇到了很多人有一些類似的問題,但它不解決我的問題。

+0

Bhavic我想你的項目,我得到了解決。 – user3182143

+0

請寄給我你的mai ID。我將發送解決的項目。 – user3182143

+0

Bhavik告訴我你的郵件ID。 – user3182143

回答

1

爲了實現這一點,您需要先設置根視圖控制器。

var window: UIWindow? 
var navController:UINavigationController? 
var viewController:ViewController? 

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{ 
    // Override point for customization after application launch. 

    window = UIWindow(frame: UIScreen.mainScreen().bounds) 
    viewController = ViewController(nibName: "subview", bundle: nil); 
    navController = UINavigationController(rootViewController: viewController!); 
    navController?.navigationBarHidden = true 
    window?.rootViewController = navController; 
    window?.makeKeyAndVisible() 
    return true 
} 

之後單擊項目

You can see now PROJECT and TARGET 
Click your project of TARGETS 
Click General. 
Now you can see the Deployment Info 
Delete the Main from Dropbox of Main Interface 

現在去子視圖XIB

Click Files's Owner of Placeholder'e. 
Then click Identity Inspector of Utility Area which is in right side. 
Click Class of CustomClass 
Then choose ViewController from Dropdown box of class and click Enter. 
And go to Connection's Inspector of Utility Area which is in right side. 
Now See the Outlets.Under Outlets, there is View.Now You have drag(Contorl+ drag the Empty Circle to Xib View) the view empty circle to the Xib View.Now empty circle is filled with black or gray color. 
Finally connect the textField and Button to Outlet. 

現在,它的工作原理perfectly- :)

+0

我下載並測試了您的應用程序。它完美無瑕。非常感謝@ user3182143。任何人都可以通過stackoverflow與我聯繫,我會把它給你 - (所有學分都發送到user3182143) –

相關問題