iOS 8 move UIView up when keyboard appears | Issue

前端 未结 3 406
逝去的感伤
逝去的感伤 2021-01-22 12:23

I have a UIView with a UITextField placed at the bottom of the screen which will move up when a keyboard appears.

I have been following the bel

3条回答
  •  清酒与你
    2021-01-22 13:07

    I used this code. It didn't move up in a scroll view. but changed their XY positions. but this is effective in my iPhone 6. i didn't check them with other iPhones.

     func textViewDidBeginEditing(textView: UITextView){
        textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y - 216 , textView.frame.size.width, textView.frame.size.height)
        buttonProp.frame = CGRectMake(buttonProp.frame.origin.x, buttonProp.frame.origin.y - 216, buttonProp.frame.size.width, buttonProp.frame.size.height)
         MessageView.frame = CGRectMake(MessageView.frame.origin.x, MessageView.frame.origin.y - 216, MessageView.frame.size.width, MessageView.frame.size.height)
         datePicked.frame = CGRectMake(datePicked.frame.origin.x, datePicked.frame.origin.y - 216, datePicked.frame.size.width, datePicked.frame.size.height)
    
    }
    
    func textViewDidEndEditing(textView: UITextView){
        textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y + 216, textView.frame.size.width, textView.frame.size.height)
         buttonProp.frame = CGRectMake(buttonProp.frame.origin.x, buttonProp.frame.origin.y + 216, buttonProp.frame.size.width, buttonProp.frame.size.height)
        MessageView.frame = CGRectMake(MessageView.frame.origin.x, MessageView.frame.origin.y + 216, MessageView.frame.size.width, MessageView.frame.size.height)
        datePicked.frame = CGRectMake(datePicked.frame.origin.x, datePicked.frame.origin.y + 216, datePicked.frame.size.width, datePicked.frame.size.height)
    }
    

    All my components are programmed to move when editing begins. and move back after editing. manual editing. yes.

提交回复
热议问题