iOS
-
iOS) Data encoding to utf8iOS 2020. 8. 31. 16:54
URLRequest를 통해 추출한 utf8 html data를 string으로 encoding 하는 과정에서 안될때가 있다. EUC-KR 형식이라면 CFStringConvertEncodingToNSStringEncoding을 이용 하자. data는 어처피 bytes utf8로 인코딩 했을때 nil이 반환 된다면 EUC-KR인지 확인 하고, 그래도 nil이 반환 된다면 data를 utf8로 되돌린다. func incodingHTML(_ data: Data) -> String? { var html = String(data: data, encoding: .utf8) guard html == nil else { return html } let encoding = String.Encoding(rawValue: C..
-
iOS) Presentation 과 Transition 그리고 Animation... (3)iOS 2020. 8. 19. 13:58
Custom Transition transtion을 구성하는 6가지의 객체 - Animation Controller - Transtion Animation을 구현 UIViewControllerAnimatedTransitioning 프로토콜을 통해 구현 transition 시간과 animation을 구현하는 두개의 필수 메소드를 가지고 있음. - Presentation Controller - 새로운 화면을 구성할 frame을 설정 하고 custom View를 관리 - Interactive Animator - interactive transition을 구현하는 객체. UIViewcontrollerInteractiveTransition + Gesture Recognizer 로 구현 - Transition De..
-
iOS) dismiss(animated:completion:)의 새로운 발견iOS 2020. 8. 14. 13:21
흔히 presenting VC에서 present한 presented VC를 닫을 때 dismiss 메소드를 사용한다. 당연히 닫을 ViewController에 dismiss(animated:completion:) 를 사용해서 원하는 VC를 닫곤 했는데, 의외의 기능을 발견 했다. 읭?? 즉 presented VC가 이미 presentation 된 상태라면 presenting VC를 dismiss 하던 presented VC를 dismiss 하던 UIKit이 알아서 dismiss 해준다고 한다.
-
iOS) TableView refresh - index out of range 오류iOS 2020. 8. 10. 12:03
TableView를 refresh 하기 위한 방법은 너무나도 간단하다. UIRefreshControl 클래스의 객체 하나를 생성해서 tableView에 subView로 추가만 해주면 된다. lazy var refreshController: UIRefreshControl = { let refreshControl = UIRefreshControl() refreshControl.attributedTitle = NSAttributedString(string: "refresh") return refreshControl }() ... if #available(iOS 10.0, *) { newsTableView.refreshControl = refreshController } else { newsTableView.a..
-
iOS) Network - ATSiOS 2020. 8. 10. 11:57
App Transport Security iOS 어플리케이션을 만들다 보면 http 통신을 하게 될 때가 있다. 이때마다 App Transport Security policy 어쩌고 하면서 컴파일 에러가 나는데, 구글링 해보면 info.plist에 가서 App Transport Security Setting을 바꿔주고 어쩌고 하라고 한다. 항상 따라만 했지 정확하게 왜 안되는지 어떻게 안되는지 몰랐기 때문에 이번 기회에 정리 해보려고 한다. 앱 심사에 중요한 역할을 한다. ATS는 iOS의 보안기능이다. TLS, AES, SHA-2를 사용한다. HTTP 통신은 데이터를 일반 텍스트로 전달하고, HTTPS는 데이터를 암호화하여 전달한다. 따라서 ATS는 기본적으로 HTTP를 허용하지 않는다. info.pl..
-
iOS) Presentation 과 Transition 그리고 Animation... (2)iOS 2020. 8. 10. 10:10
Custom Presentation UI를 구성하는 기능은 View Controller가 VC에 화면을 표시하는 기능은 presentation controller가 담당한다. 기본 presentation(ex.full screen, sheet..)을 사용한다면 Presentation Controller가 자동으로 생성된다. presentation을 custom으로 만든다면, 직접 presentation controller를 설정해주어야 한다. 이 presentation controller는 transition animation을 실행한다. custom view를 관리하는 것도 presentation controller의 역할이다. UIPresentationController 통해 presentation을..
-
iOS) Presentation 과 Transition 그리고 Animation... (1)iOS 2020. 8. 7. 07:52
iOS 어플리케이션을 사용하다 보면 화려하고 신기한 애니메이션 효과, 화면 전환 효과로 UI/UX의 중요성을 더욱 강조 시켜준다. Transition과 Animation 기술을 연마하던 중 그 동안 무심코 썼던 VC간 화면 전환에 대해 정리할 필요가 있다고 느껴졌다. 사실 이 글을 쓰기 전까지도 presentation와 Transition의 명확한 구분이 가지 않았다.. iOS를 처음 접했을 땐 스토리보드를 통한 Segue를 사용 했다. 단순히 선을 연결하고 Navigation Controller에 속해 있다면 Show 아니라면 present modally를 선택했을 뿐이였다. present modally를 선택하면 modalPresentationStyle이 등장 한다. 엥 근데 그 밑에 modalTra..