2015-10-15 61 views
0

我有這個簡單的鍵盤,但我試圖打印到控制檯不會顯示...任何想法?這一切都是在keybaord目標的文件夾內完成的,下面是代碼:自定義鍵盤ViewDidLoad方法不打印到控制檯

import UIKit 

class KeyboardViewController: UIInputViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { 

    @IBOutlet var nextKeyboardButton: UIButton! 
    @IBOutlet var collectionView: UICollectionView! 

    override func updateViewConstraints() { 
     super.updateViewConstraints() 
     // Add custom view sizing constraints here 
    } 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     print("keyboard view loaded") 

     //keyboard nib setup 
     let nib = UINib(nibName: "KeyboardView", bundle: nil) 
     let objects = nib.instantiateWithOwner(self, options: nil) 
     view = objects[0] as! UIView 

     //cell setup 
     collectionView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellWithReuseIdentifier: "MyCell") 

     // Perform custom UI setup here 
     self.nextKeyboardButton = UIButton(type: .System) 

     self.nextKeyboardButton.setTitle(NSLocalizedString("Next Keyboard", comment: "Title for 'Next Keyboard' button"), forState: .Normal) 
     self.nextKeyboardButton.sizeToFit() 
     self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = false 

     self.nextKeyboardButton.addTarget(self, action: "advanceToNextInputMode", forControlEvents: .TouchUpInside) 

     self.view.addSubview(self.nextKeyboardButton) 

     let nextKeyboardButtonLeftSideConstraint = NSLayoutConstraint(item: self.nextKeyboardButton, attribute: .Left, relatedBy: .Equal, toItem: self.view, attribute: .Left, multiplier: 1.0, constant: 0.0) 
     let nextKeyboardButtonBottomConstraint = NSLayoutConstraint(item: self.nextKeyboardButton, attribute: .Bottom, relatedBy: .Equal, toItem: self.view, attribute: .Bottom, multiplier: 1.0, constant: 0.0) 
     self.view.addConstraints([nextKeyboardButtonLeftSideConstraint, nextKeyboardButtonBottomConstraint]) 

    } 

謝謝!

+0

我們將需要比這更多一點。你可以發佈更多的代碼,更多地解釋你在做什麼? –

回答

1

由於鍵盤是你需要爲了調試它,而不是應用程序運行的擴展延伸。主動方案設置爲你的鍵盤

enter image description here

裏面它意味着你加載擴展的E中的圓圈。它會讓你選擇一個應用程序來運行擴展。只要你在那個應用程序,當你提起鍵盤它應該工作。