2016년 11월 27일 일요일

[ios swift 3] 코드로 layout 잡기

storyboard에서 레이아웃을 잡은 후 기기에서 테스트해보면 원하는대로 제대로 안되는 경우가 있다.

(예로 scrollview에 label, image view등을 넣어서 위치를 잡은 후 label이 멀티라인이 되어야 해서 label 아래의 view등의 y값을 앱 실행단계에서 정해 주어야 할 때)

// 기존 값을 모두 무시하도록 한다. (storyboard 상에서 값을 지정한 경우)

view.translatesAutoresizingMaskIntoConstraints = false

// 각 constraint를 직접 설정한다.
// item에 원하는 뷰 지정
// attribute에 원하는 속성
// toItem에 기준이 될 view 지정
// constant에 거리 지정

let leading = NSLayoutConstraint(item:view, attribute:.leading, relatedBy:.equal, toItem:scrollView, attribute:.leading, multiplier:1, constant:16)


// 마지막으로 모든 설정들을 활성화 해준다.
NSLayoutConstraint.activate([leading,,,,])


// label에 멀티 라인 지정시 height 계산
label에 text 넣고
label.sizeToFit()를 실행 한 후 height값을 가져오면 된다.

[ios swift 3] navigationBar, tabBar 배경색 지정

네비게이션바와 탭바에는 기본적으로 투명도가 적용되어 있어서 인지 원하는 색상을 bar tint에 지정하는 것만으로는 안된다. 투명도설정을 제거해 주어야만 한다.

story board에서는
Bar Tint 색상 지정
Translucent 체크 해제

코드상으로는 아래와 같이
self.navigationController?.navigationBar.barTintColor = UIColor.black
self.navigationController?.navigationBar.isTranslucent = false

translucent 를 false로 할 경우 간혹 다른 이슈가 발생할 수 있다.

 tabbar를 생성후 안드로이드 처럼 위치를 위로 올렸을 경우 기존 tabbar 위치에 터치가 되지 않는 경우

이럴 경우에는 해당 viewcontroller에 아래와 같은 코드 삽입

self.extendedLayoutIncludesOpaqueBars = true

[ios swift 3] http json 통신

1. GET 방식

let url = URL(string:"")
var request = URLRequest(url:url!)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with:request) { data, response, err in
if err != nil {
Utils.Log("error::\(err)")
} else {
do {
let json = try JSONSerialization.jsonObject(with:data!, options:.mutableContainers) as! [String:AnyObject]

let status = json["status"] as! Bool
if status {
}
} catch {
Utils.Log("error::\(error)")
}
}
}
task.resume()

만약 데이터에 한글이 있을 경우
let link = "url string"
// 한글 처리
let url:URL = URL(string:link.addingPercentEncoding(withAllowedCharacters:.urlQueryAllowed)!)!


2. POST 방식

let json = ["type":value, "type":value] as [String:Any]
var jsonData:Data
do {
jsonData = try JSONSerialization.data(withJSONObject:json, options:.prettyPrinted)
} catch {
Utils.Log("error::\(error)")
return
}

let url:URL = URL(string:"")!
var request:URLRequest = URLRequest(url:url)
request.httpMethod = "POST"
request.httpBody = jsonData
let task = URLSession.shared.dataTask(with:request) { data, response, err in
if err != nil {
Utils.Log("error::\(err)")
} else {
do {
let str = String(data:data!, encoding:.utf8)
Utils.Log("str::\(str)")
let json = try JSONSerialization.jsonObject(with:data!, options:.mutableContainers) as! [String:AnyObject]

let status = json["status"] as! Bool
if status {
}
} catch {
Utils.Log("error::\(error)")
}
}
}
task.resume()

2016년 10월 28일 금요일

[iptime 공유기] wifi 연결 끊김 문제 해결

공유기 변경 후 무선 인터넷 연결이 자꾸 끊기는 경우가 발생.
아래와 같이 설정 변경

192.168.0.1 로 접근후
고급 설정 > 무선랜 관리 > 무선 고급 설정에서

1. 채널 크기를 자동으로 설정
2. WMM 기능을 사용하지 않음으로 설정
3. RTS Threshold 수치를 2000으로 변경
4. Fragmentation Threshold 수치를 2000으로 변경 후 적용
5. beacon주기를 80으로 변경

2016년 9월 1일 목요일

[Windows] 키보드 숫자 키패드를 마우스로 사용하기

윈도우에 이런 기능이 있는 줄 몰랐네
예전 IBM의 빨콩 같은 기능정도를 기대했지만... 쩝 그렇게 좋지 않다.
걍 마우스 없거나 정말 마우스 쓰기 귀찮을때만...

http://windowstalk.co.kr/393

2016년 8월 26일 금요일

[자동차] 하이패스 자동 충전 선불카드

신청은 아래
http://www.hipluscard.co.kr/

카드신청 > 자동충전카드 신청 페이지에서

후불카드는 연회비가 있지만
선불카드라서 연회비 없고 자동으로 충전이 되니까 귀찮지 않고...

2016년 6월 22일 수요일

2016년 5월 31일 화요일

[윈도우] 삭제하기 어려운 악성프로그램 삭제하기

WindowexeAllkiller를 사용해서 삭제하자.
주위할 점은 체크안한 것이 삭제된다.

한 번 실행하면 실행한 내용이 저장되어 다음 실행시 체크하는 화면 없이 바로 실행되어 버린다. 그럴 땐 같은 폴더에 있는 WindowexeAllkiller.txt 파일을 삭제하고 실행하자.

http://www.windowexeallkiller.com/k.php?q=wactivity-c-users-administrator-appdata-roaming-wactivity-wactivity-exe

2016년 5월 3일 화요일

[Mac OS] Synergy client 자동 실행

Mac os에서 synergy client 자동 실행하기

AppleScript로 아래와 같은 파일을 생성한다.
======================================================================
try
do shell script "killall .synergyc "
end try

ignoring application responses
do shell script "/Applications/Synergy.app/Contents/MacOS/synergyc -n kodeglamui-Mac-mini.local 192.168.0.89"
end ignoring
======================================================================
파일은 Application 폴더에 application 유형으로 저장한다.

그리고 시스템 환결설정 > 사용자및 그룹 > 로그인 항목에 위에 만든 파일을 가져다 놓는다
이때 "가리기"는 체크해제 할 것

로그인은 자동으로 하는 것이 편함...

2016년 1월 11일 월요일