본문 바로가기

iOS

(28)
[Swift] characteristic read, write //read devicePeripheral.readValue(for: characteristic) //write var parameter = NSInteger(0x31) let data = Data(bytes: &parameter, count: 1) devicePeripheral.writeValue(data, for: characteristic, type: .withResponse) 연결된 peripheral 의 characteristic 은 배열에 따로 저장해 두자.
[Swift] contentView - expandable tableView 왜인지 정확하게 파악은 안되지만 확장 테이블 뷰 사용시 아래 코드중 위의 코드에서는 버튼이 오동작했고, 아래 코드에서는 버튼이 정상 동작하였다. 커스텀하게 사용할때 뭔가 다른 차이점이 있는 것 같기는 한데 아직 파악이 어렵다. addSubview(tableButton) contentView.addSubview(tableButton)
[Swift] Google Admob 추가 cocoapod 으로 admob 설치 후. import SnapKit import GoogleMobileAds func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { GADMobileAds.sharedInstance().start(completionHandler: nil) return true } private var bannerView: GADBannerView! override func viewDidLoad() { super.viewDidLoad() let adSize = GADAdSizeFromCGSiz..
[Swift] modalPresentationStyle 코드로 다른 contorller view 를 불러올때, 크기를 이어받을 것인지, 풀로 불러올 것인지 정할 수 있음. 나는 주로 맥북에서 테스트 시에 쓰게 됨. svc.modalPresentationStyle = .currentContext //이전 cv와 동일 svc.modalPresentationStyle = .fullScreen //이전 cv와 상관 없이 풀스크린
[Swift] 작업영역에서 Statusbar 제외하기 아래 코드 참고. import UIKit import SnapKit import Foundation class MyMainView: UIViewController { let safetyArea: UIView = { let v = UIView() return v }() lazy var myButtonTop: UIButton = { let btn = UIButton() btn.setTitle("My Button(T)", for: .normal) btn.backgroundColor = UIColor.blue return btn }() override func viewDidLoad() { super.viewDidLoad() setBaseView() setView() } func setBaseView(){ saf..
[Swift] SnapKit UI를 코드로 편하게 작성하기 위해 사용하는 라이브러리 https://github.com/SnapKit/SnapKit
[Swift] Lazy 변수 불러오기 전까지는 연산되지 않음. 따라서 메모리 절약 가능 Lazy var funcName: ~
[Swift] Storyboard 없이 코드로 프로젝트 시작하기 1. Main.storyboard 삭제 2. Targets -> General 에서 Main Interface 삭제 3. info.plist -> Application Scene Manifest -> Storyboard Name 삭제 4. SceneDelegate -> func scene을 아래 내용으로 대체, ViewController() //시작 뷰 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure and attach the UIWindow `window`..