티스토리 뷰

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import UIKit
 
class WritePostViewController: UIViewController ,UITextFieldDelegate ,UITextViewDelegate{
    @IBOutlet weak var titleField: UITextField!
    @IBOutlet weak var contentField: UITextView!
 
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.titleField.delegate = self
        self.contentField.delegate = self
    }
 
    override func viewDidAppear(animated: Bool) {
        self.titleField.becomeFirstResponder()//텍스트필드에 포커스
    }
 
    //키보드 delegate
    func textFieldShouldReturn(textField: UITextField) -> Bool {
        if(textField.isEqual(self.titleField)){ //titleField에서 리턴키를 눌렀다면
            self.contentField.becomeFirstResponder()//컨텐츠필드로 포커스 이동
        }
        return true
    }
 
    func endEdit(){
        self.contentField.resignFirstResponder()//키보드 숨기기
    }
}
cs


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday