This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { | |
//์ด์ ๊ธ์ - ์ ํ๋ ๊ธ์ + ์๋ก์ด ๊ธ์(๋์ฒด๋ ๊ธ์) | |
let newLength = textView.text.count - range.length + text.count | |
let koreanMaxCount = maxCount + 1 | |
//๊ธ์์๊ฐ ์ด๊ณผ ๋ ๊ฒฝ์ฐ or ์ด๊ณผ๋์ง ์์ ๊ฒฝ์ฐ | |
if newLength > koreanMaxCount { //11๊ธ์ | |
let overflow = newLength - koreanMaxCount //์ด๊ณผ๋ ๊ธ์์ | |
if text.count < overflow { | |
return true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { | |
let newLength = textView.text.count - range.length + text.count | |
if newLength > maxCount { | |
return false | |
} | |
return true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func textViewDidEndEditing(_ textView: UITextView) { | |
if textView.text.isEmpty { | |
textView.text = "์๊ฒฌ์ ์ ๋ ฅํด์ฃผ์ธ์. (์ต์ 10์, ์ต๋ 1000์)" | |
textView.textColor = UIColor.lightGray | |
} | |
if textView.text.count > textViewMaximumCount { | |
textView.text.removeLast() | |
textViewTextNumLabel.text = "\(textViewMaximumCount)" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { | |
guard let str = textView.text else {return true} | |
let newLength = str.count + text.count - range.length | |
return newLength <= textViewMaximumCount + 1 | |
} | |
func textViewDidChange(_ textView: UITextView) { | |
guard let text = textView.text else { return } | |
let num: Int = text.count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc func keyboardWillShow(_ notification: Notification?) | |
{ | |
//ํค๋ณด๋ frame ๋ฐ ํค๋ณด๋๊ฐ ์ฌ๋ผ์จ ์ํ์ธ์ง ์๋์ง Bool ๊ฐ ๋ฐ์์ค๊ธฐ | |
guard let info = notification?.userInfo else { | |
return | |
} | |
let frameEndUserInfoKey = UIResponder.keyboardFrameEndUserInfoKey | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() | |
{ | |
super.viewDidLoad() | |
doSomething() | |
} | |
override func viewWillDisappear(_ animated: Bool) | |
{ | |
super.viewWillDisappear(animated) | |
//ํ๋ฉด์ด ๋ด๋ ค๊ฐ ๋ Notification ์ญ์ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func | |
let toolBarKeyboard = UIToolbar() | |
toolBarKeyboard.sizeToFit() | |
let btnDoneBar = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(self.doneBtnTouched)) | |
toolBarKeyboard.items = [btnDoneBar] | |
toolBarKeyboard.tintColor = .blue | |
self.textView.inputAccessoryView = toolBarKeyboard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoticeBoardViewController: UIViewController | |
{ | |
override func viewDidLoad() | |
{ | |
super.viewDidLoad() | |
doSomething() | |
} | |
func doSomething() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Home { | |
enum Category: String { | |
case KakaoLogin = "Kakao Login" | |
case RestfulApi = "get restfulAPI DATA" | |
case PopupVC = "Custom PopupViewController" | |
case KakaoMap = "Kakao Map" | |
case NoticeBoard = "Notice Borad" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { | |
//์๋ธ๋ทฐ์ ํด๋น ์นดํ ๊ณ ๋ฆฌ๋ฅผ ๋๊ฒจ์ฃผ๊ธฐ ์ํ ์์ (์ถํ router์์ ์ฐ์) | |
let category = category[indexPath.row] | |
//๋ค์ ํ๋ฉด์ด ๋ฌด์์ธ์ง์ ๋ฐ๋ผ ๋ค๋ฅธ ์์ | |
switch category { | |
case .NoticeBoard: |
NewerOlder