デザインの下部に UITextView があります。何かを書き込もうとすると、キーボードが下がったままになるため、キーボードの高さを増やしますが、問題があります。キーボードはTextViewの前から来ており、見栄えがよくありません。ただし、Whatsappおよびswarmアプリケーションでは、このキーボードがTextViewと同時に増加するようにはなりません。どうすればタイミングを合わせることができますか。以下で私のコードを見ることができます
var frameMessageView = UIView()
var mesajtext = UITextView()
var resultScrollView = UIScrollView()
var lblcizgi = UILabel();
var topImg = UIImageView();
let place = ""
override func viewDidLoad() {
super.viewDidLoad()
self.automaticallyAdjustsScrollViewInsets = false
let theWidth = view.frame.size.width
let theHeight = view.frame.size.height
let backButton = UIBarButtonItem(title: "Geri", style: UIBarButtonItemStyle.Plain, target: self, action: "goBack:")
navigationItem.leftBarButtonItem = backButton
navigationItem.leftBarButtonItem?.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Helvetica Neue", size: 15.0)!], forState: UIControlState.Normal)
self.tabBarController?.tabBar.hidden = true
webView.delegate = self
webView.scrollView.bounces = false
resultScrollView.frame = CGRectMake(0, 67, theWidth, theHeight-112)
resultScrollView.backgroundColor = UIColor.blueColor()
topImg.frame = CGRectMake(0, 64, theWidth, 3)
topImg.image = UIImage(named:"top-bottom")
webView.frame = CGRectMake(0, 0, self.resultScrollView.frame.size.width, UIScreen.mainScreen().bounds.height-102)
view.backgroundColor = UIColor.blackColor()
frameMessageView.frame = CGRectMake(0, theHeight - 45, theWidth, 45)
frameMessageView.backgroundColor = UIColor(red: 247.0/255.0, green: 247.0/255.0, blue: 247.0/255.0, alpha: 1.0)
mesajtext.font = UIFont(name: "Helvetica Neue", size: 15.0)
mesajtext.frame = CGRect(x: 10, y: 10, width: self.view.frame.size.width - 75, height: 27)
mesajtext.backgroundColor = UIColor.whiteColor()
mesajtext.layer.cornerRadius = 5.0
mesajtext.layer.masksToBounds = true
mesajtext.layer.borderColor = UIColor( red: 203/255, green: 203/255, blue:203/255, alpha: 1.0 ).CGColor
mesajtext.layer.borderWidth = 1.0
lblcizgi.frame = CGRectMake(0, 0, frameMessageView.frame.width, 1)
lblcizgi.backgroundColor = UIColor(red: 203/255, green: 203/255, blue: 203/255, alpha: 0.5)
let button = UIButton()
button.frame = CGRectMake(self.view.frame.maxX-65, 13, 60, 20)
//button.backgroundColor = UIColor(red: 251.0/255.0, green: 188.0/255.0, blue: 5.0/255.0, alpha: 1.0)
button.setTitle("Gönder", forState: UIControlState.Normal)
button.setTitleColor(UIColor(red: 27/255, green: 119/255, blue: 218/255, alpha: 1.0), forState: UIControlState.Normal)
button.addTarget(self, action: "gonderbutonclick:", forControlEvents: UIControlEvents.TouchUpInside)
button.titleLabel!.font = UIFont(name:"Helvetica Neue", size: 14.0)
applyPlaceholderStyle(mesajtext , placeholderText: place)
mesajtext.delegate = self
frameMessageView.addSubview(lblcizgi)
frameMessageView.addSubview(mesajtext)
frameMessageView.addSubview(button)
view.addSubview(frameMessageView)
view.addSubview(resultScrollView)
view.addSubview(topImg)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWasShown:", name: UIKeyboardDidShowNotification, object: nil)
}
func keyboardWasShown(notification: NSNotification) {
let dict:NSDictionary = notification.userInfo!
let s:NSValue = dict.valueForKeyPath(UIKeyboardFrameEndUserInfoKey) as! NSValue
let rect:CGRect = s.CGRectValue()
UIView.animateWithDuration(0, delay: 0, options: UIViewAnimationOptions.CurveLinear, animations: { () -> Void in
self.resultScrollView.frame = CGRectMake(0, 67, self.view.frame.size.width, self.view.frame.height-rect.height-112)
self.frameMessageView.frame.origin.y = self.resultScrollView.frame.maxY
}) { (Bool) -> Void in
}
}