일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 30 | 31 |
- Excel
- node.js
- ubuntu
- Linux
- MS-SQL
- flutter
- sqlite
- MySQL
- urllib
- GIT
- swift
- PyQt5
- IOS
- ASP
- PyQt
- mssql
- pandas
- 라즈베리파이
- 날짜
- PER
- python
- 유니티
- 다이어트
- port
- 맛집
- javascript
- 함수
- 리눅스
- Unity
- tensorflow
목록랭귀지/SWIFT (81)
아미(아름다운미소)
WebView HTML 파일 로딩 func loadPageWithUrlString(urlString : String) { if let url = URL(string : urlString) { webView.loadRequest(URLRequest(url: url)) } } @IBAction func fileClicked(_ sender: AnyObject) { if let path = Bundle.main.path(forResource: "Sample", ofType : "html") { loadPageWithUrlString(urlString: path) } }
nil 전달 함수 var lampOn:Bool? = false func lampOnOffRemove(isOn : Bool?) { if let onOff = isOn { self.lampOn = onOff self.lampImageView.image = UIImage(named : onOff ? "lamp-on.png" : "lamp-off.png") } else { self.lampOn = nil self.lampImageView.image = UIImage(named : "lamp-remove.png") } } @IBAction func lampOffClicked(_ sender: AnyObject) { if lampOn! { //
스위프트(Swift)로 코딩을 하며 iOS어플 개발을 하다보면 HTTP연결이 제한되는 경우가 있습니다.iOS9부터 HTTP가 아닌 HTTPS로의 접근만 허용해놨기 때문인데요. info.plist파일의 HTTP 연결 권한을 줘야 정상적으로 통신이 가능합니다. - 모든사이트 오픈 NSAppTransportSecurity NSAllowsArbitraryLoads - 해당사이트만 오픈 NSAppTransportSecurity NSExceptionDomains yourserver.com NSExceptionAllowsInsecureHTTPLoads
가끔 숫자값을 3자리 단위로 콤마(,)를 추가하여 자릿수를 구분해주는 기능이 필요할 경우 extension Int { var withComma: String { let decimalFormatter = NumberFormatter() decimalFormatter.numberStyle = NumberFormatter.Style.decimal decimalFormatter.groupingSeparator = "," decimalFormatter.groupingSize = 3 return decimalFormatter.string(from: self as NSNumber)! } } extension String { var delComma: String { if self.characters.count > 0 ..
코드로 정의하기 스토리보드를 이용하지 않고 코드상으로 연결하는 방법입니다. @IBAction private func playBtn(_ sender: UIButton) { let vc = self.storyboard?.instantiateViewController (withIdentifier: "Resultsidentifer") as! ResultsViewController vc.userChoice = getUserShape(sender) present(vc, animated: true, completion: nil) } withIdentifier의 "Resultsidentifer" 부분은 두 번째 view controller의 identifer이고 그 뒤 ResultsViewController는 clas..
- Swift 2 func convertStringToDictionary(text: String) -> [String:AnyObject]? { if let data = text.dataUsingEncoding(NSUTF8StringEncoding) { do { return try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String:AnyObject] } catch let error as NSError { print(error) } } return nil } let str = "{\"name\":\"James\"}" let result = convertStringToDictionary(str) - Swift 3 func convert..
페이지 컨트롤페이지 컨트롤(Page Control)은 여러 페이지 중에서 현재 페이지를 알려 주는 역활을 합니다.현재 뷰에서 보여 주려는 내용이 여러 개일 때 사용합니다. 갤러리나 아이폰 홈 화면과 같은 앱에서 전체 페이지 중 현재 페이지가 어느 부분에 있는지 알려 줄 때 사용합니다. 위치 뷰 컨트롤러의 클래스 선언문 바로 아래 연결(Connection) Outlet 이름(Name) imgView 유형(Type) UIImageView 위치 imgView 아웃렛 변수 아래 연결(Connection) Outlet 이름(Name) pageControl유형(Type) UIPageControl 위치 뷰컨트롤러 클래스 맨 아래 연결(Connection) Action 이름(Name) pageChanged유형(Type..
위치와 경도로 원하는 핀 설치하기 위치 마지막줄 연결(Connection) Action 이름(Name) sgChangeLocation 유형(Type) UISegmentedControl [전체소스] import UIKitimport MapKit class ViewController: UIViewController, CLLocationManagerDelegate{ @IBOutlet weak var myMap: MKMapView! @IBOutlet weak var lblLocationInfo1: UILabel! @IBOutlet weak var lblLocationInfo2: UILabel! let locationManager = CLLocationManager() override func viewDidLoa..
- 위치 정보를 추출해서 텍스트로 표시하기 위치 myMap 아웃렛 변수 바로 아래 연결(Connection) Outlet 이름(Name) lblLocationInfo1 유형(Type) UILabel 위치 lblLocationInfo1 아웃렛 변수 바로 아래 연결(Connection) Outlet 이름(Name) lblLocationInfo2 유형(Type) UILabel [해당소스] @IBOutlet weak var lblLocationInfo1: UILabel! @IBOutlet weak var lblLocationInfo2: UILabel! CLGeocoder().reverseGeocodeLocation(pLocation!, completionHandler: { (placemarks, error) -..
위도와 경도로 원하는 위치 표시하기 [해당 소스] func goLocation(latitude latitudeValue: CLLocationDegrees, longitude longitudeValue : CLLocationDegrees, delta span :Double) { //위도 값과 경도 값을 매개변수로 하여 CLLocationCoordinate2DMake 함수를 호출하고, 리턴값을 pLocation로 받습니다. let pLocation = CLLocationCoordinate2DMake(latitudeValue, longitudeValue) //범위 값을 매개변수로 하여 MKCoordinateSpanMake함수를 호출하고, 리턴 값을 spanValue로 받습니다. let spanValue = M..