         if UIApplication.sharedApplication().canOpenURL(searchURL){
             UIApplication.sharedApplication().openURL(searchURL)
         }
+    }
+    
+    //UITextFieldが編集された直後に呼ばれる.
+    func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
+        txtActiveField = textField
+        return true
+    }
+    
+    func keyboardWillShow(notification: NSNotification){
+        let userInfo = notification.userInfo!
+        let keyboardScreenEndFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
+        let myBoundSize: CGSize = UIScreen.mainScreen().bounds.size
+        let txtLimit = txtActiveField.frame.origin.y + txtActiveField.frame.height + 72
+        let kbdLimit = myBoundSize.height - keyboardScreenEndFrame.size.height
+        
+        if txtLimit >= kbdLimit {
+            scrollview.contentOffset.y = txtLimit - kbdLimit
+        }
+    }
+    
+    func keyboardWillHide(notification: NSNotification){
+        self.scrollview.contentOffset.y = 0
     }
     
     //UITableDelegate

        AuthSw.addTarget(self, action: "onClickMySwicth:", forControlEvents: UIControlEvents.ValueChanged)
        NameSw.addTarget(self, action: "onClickMySwicth:", forControlEvents: UIControlEvents.ValueChanged)
        TestModeSw.addTarget(self, action: "onClickMySwicth:", forControlEvents: UIControlEvents.ValueChanged)
        
        let str = "http://gae.cavelis.net/user/\(self.Api.auth_user)"
        let url:NSURL! = NSURL(

    @IBOutlet weak var titleText: UITextField!
    @IBOutlet weak var detailText: UITextView!
    @IBOutlet weak var tagText: UITextField!
    
    @IBOutlet weak var ComIDSw: UISwitch!
    @IBOutlet weak var AuthSw: UISwitch!
    @IBOutlet weak var NameSw: UISwitch!
    @IBOutlet weak var TestModeSw: UISwitch!
    
    @IBOutlet weak var genreTable: UITableView!
    @IBOutlet weak var thubmTable: UITableView!
    @IBOutlet weak var PresetTable: UITableView!
    
    @IBOutlet weak var scrollview: UIScrollView!
    
    let Api = CaveAPI()
