COMPUTER/swift
- swift image blur 2016.10.04
- swift3 system log remove 2016.09.27
- UiTableView에서 텍스트 양에 따라 크기 조절하기. 2016.09.21
- uitableview 기타등등 기능. 2016.09.20
- swift tab 2016.09.19
- swift 간단 animation 효과 2016.08.10
- API 호출시 UI 멈춤 해결 2016.07.28 1
- swift에서 web을 통해 json 받아오기 2016.07.20 1
swift image blur
swift 2.0
func applyBlurEffect(image: UIImage){
let imageToBlur = CIImage(image: image)
let blurfilter = CIFilter(name: "CIGaussianBlur")
blurfilter.setValue(imageToBlur, forKey: "inputImage")
let resultImage = blurfilter.valueForKey("outputImage") as CIImage
let blurredImage = UIImage(CIImage: resultImage)
return blurredImage
}
swift 3.0
func applyBlurEffect(image: UIImage)->UIImage{
let imageToBlur = CIImage(image: image)
let blurfilter = CIFilter(name: "CIGaussianBlur")
blurfilter?.setValue(imageToBlur, forKey: "inputImage")
let resultImage = blurfilter?.value(forKey: "outputImage") as! CIImage
let blurredImage = UIImage(ciImage: resultImage)
return blurredImage
}
more speed blur for UIImageView
let darkBlur = UIBlurEffect(style: UIBlurEffectStyle.light)
// 2
let blurView = UIVisualEffectView(effect: darkBlur)
blurView.frame = (UIImageViewVar?.bounds)!
// 3
UIImageViewVar?.addSubview(blurView)
'COMPUTER > swift' 카테고리의 다른 글
swift3 system log remove (0) | 2016.09.27 |
---|---|
UiTableView에서 텍스트 양에 따라 크기 조절하기. (0) | 2016.09.21 |
uitableview 기타등등 기능. (0) | 2016.09.20 |
swift tab (0) | 2016.09.19 |
swift 간단 animation 효과 (0) | 2016.08.10 |
swift3 system log remove
swift3
xcode8
system log
여기보고 했음
http://stackoverflow.com/questions/37800790/hide-strange-unwanted-xcode-8-logs
2016-06-13 16:33:34.406093 TestiOS10[8209:100611] bundleid: com.appc.TestiOS10, enable_level: 0, persist_level: 0, propagate_with_activity: 0
2016-06-13 16:33:34.406323 TestiOS10[8209:100607] Created DB, header sequence number = 248
2016-06-13 16:33:34.409564 TestiOS10[8209:100611] subsystem: com.apple.UIKit, category: HIDEvents, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-13 16:33:34.504117 TestiOS10[8209:100607] Created DB, header sequence number = 248
2016-06-13 16:33:34.548023 TestiOS10[8209:100607] subsystem: com.apple.BaseBoard, category: MachPort, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-13 16:33:34.568458 TestiOS10[8209:100608] subsystem: com.apple.FrontBoard, category: Common, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
이런 에러 나올때
1.
Xcode 메뉴 중 이렇게.
이런걸 써서 추가하면 안나옴
OS_ACTIVITY_MODE
= disable
- Product -> Scheme -> Edit Scheme
'COMPUTER > swift' 카테고리의 다른 글
swift image blur (0) | 2016.10.04 |
---|---|
UiTableView에서 텍스트 양에 따라 크기 조절하기. (0) | 2016.09.21 |
uitableview 기타등등 기능. (0) | 2016.09.20 |
swift tab (0) | 2016.09.19 |
swift 간단 animation 효과 (0) | 2016.08.10 |
UiTableView에서 텍스트 양에 따라 크기 조절하기.
http://www.appcoda.com/self-sizing-cells/
여기서 본걸로 해결.
텍스트 상하좌우 constraints를 주고
Lines 설정하는 것을 0으로 한뒤
-> 이거로도 되네. ( label!.numberOfLines = 0 )
셀크기를 유동적으로 변하게 하기 위해서 아래 코드를..
self.tableView.estimatedRowHeight = 168.0
self.tableView.rowHeight = UITableViewAutomaticDimension
요로코롬 하니. 내용에 따라 셀 크기가 변함.
UIlabel 크기도 변함.
'COMPUTER > swift' 카테고리의 다른 글
swift image blur (0) | 2016.10.04 |
---|---|
swift3 system log remove (0) | 2016.09.27 |
uitableview 기타등등 기능. (0) | 2016.09.20 |
swift tab (0) | 2016.09.19 |
swift 간단 animation 효과 (0) | 2016.08.10 |
uitableview 기타등등 기능.
swift2.0
구분선 제거
tableView.separatorStyle = .None
:hover라 하기도 하고 selected 라고도 하는 선택된 셀 색상 color
let bgColorView = UIView()
bgColorView.backgroundColor = UIColor.blackColor()
cell.selectedBackgroundView = bgColorView
swift3.0
구분선 제거
tableView.separatorStyle = .none
:hover라 하기도 하고 selected 라고도 하는 선택된 셀 색상 color
let bgColorView = UIView()
bgColorView.backgroundColor = UIColor.black
cell.selectedBackgroundView = bgColorView
선택된 셀 변화 안시키기
cell.selectionStyle = .none
'COMPUTER > swift' 카테고리의 다른 글
swift3 system log remove (0) | 2016.09.27 |
---|---|
UiTableView에서 텍스트 양에 따라 크기 조절하기. (0) | 2016.09.21 |
swift tab (0) | 2016.09.19 |
swift 간단 animation 효과 (0) | 2016.08.10 |
API 호출시 UI 멈춤 해결 (1) | 2016.07.28 |
swift tab
AppDelegate.swift
.
이거에서
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
UITabBar.appearance().translucent = false
UITabBar.appearance().barTintColor = UIColor(rgba: "#12296f")
UITabBar.appearance().tintColor = UIColor.whiteColor()
return true
}
이로코롬.
UIColor(rgba: "#12296f")
이거는 안된다.
UIColor.
이렇게 쓰고 뒤에는 색상으로 해서 했다.
색상 자유롭게 하는거 찾아봐야지
'COMPUTER > swift' 카테고리의 다른 글
UiTableView에서 텍스트 양에 따라 크기 조절하기. (0) | 2016.09.21 |
---|---|
uitableview 기타등등 기능. (0) | 2016.09.20 |
swift 간단 animation 효과 (0) | 2016.08.10 |
API 호출시 UI 멈춤 해결 (1) | 2016.07.28 |
swift에서 web을 통해 json 받아오기 (1) | 2016.07.20 |
swift 간단 animation 효과
스위프트 간단 애니매이션 효과
기본 Animation
UIView.animateWithDuration(
//동작 시간, 준비시간
1.0, delay: 0.0,
//옵션이라는데 알아봐야할듯 속도조절부분 인듯 한데
options: UIViewAnimationOptions.CurveEaseOut,
//Animation 내용
animations: {
//ex 투명도를 1로 바꿈(원래 0, 투명한 상태)
self.StackView.frame.origin.y -= 10
}, completion: nil
)
이부분 사용법 [ completion: nil ]
UIView.animateWithDuration(
1.0, delay: 0.0,
options: UIViewAnimationOptions.CurveEaseOut,
animations: {
//Animation 내용
//ex
self.StackView.frame.origin.y -= 10
}, completion: {
(finished: Bool) -> Void in
//사용할 기능 추가
}
)
이런식으로 사용.
completion에 애니매이션을 넣어서
애니매이션 후 애니매이션 가능.
기본 애니메이션 기능
'COMPUTER > swift' 카테고리의 다른 글
uitableview 기타등등 기능. (0) | 2016.09.20 |
---|---|
swift tab (0) | 2016.09.19 |
API 호출시 UI 멈춤 해결 (1) | 2016.07.28 |
swift에서 web을 통해 json 받아오기 (1) | 2016.07.20 |
스위프트 기초 (0) | 2016.02.16 |
API 호출시 UI 멈춤 해결
확실한 것은 아니지만
post 로 통신을 하면서
전송 완료 후에 화면에 관련된 먼가를 하면 친숙한
에러가 계속 보였다.
계속되는 오류 속에 이거 인듯하다 라는 것을 적어둬야지.
let postString = "id=\(id)&pw=\(pw)"
print(postString)
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in
guard error == nil && data != nil else {
// check for fundamental networking error
print("error=\(error)")
return
}
if let httpStatus = response as? NSHTTPURLResponse where httpStatus.statusCode != 200 {
// check for http errors
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print("response = \(response)")
}
let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
//로그인 성공
guard responseString=="false" else {
self.LoginSuccess()
return
}
//로그인 실패
NSLog("로그인 실패")
}
task.resume()
기본소스는 이거 하지만...
self.LoginSuccess() 여기서 화면 전환이 이루어지는데
계속 오류남....
오류내용.
로그인 실패 = Optional(false)
2016-07-28 13:06:45.916 MyAPP[10681:3224463] *** Assertion failure in -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/Keyboard/UIKeyboardTaskQueue.m:386
2016-07-28 13:06:45.920 MyAPP[10681:3224463] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000104e61d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000106c05deb objc_exception_throw + 48
2 CoreFoundation 0x0000000104e61bea +[NSException raise:format:arguments:] + 106
3 Foundation 0x00000001052b2d5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 UIKit 0x00000001060c4a73 -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] + 165
5 UIKit 0x000000010592bdc9 -[UIKeyboardImpl setDelegate:force:] + 1085
6 UIKit 0x0000000105cf7d05 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1040
7 UIKit 0x0000000105d00824 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 475
8 UIKit 0x0000000105835c5a -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1175
9 UIKit 0x000000010583794d -[UIViewController _presentViewController:withAnimationController:completion:] + 4916
10 UIKit 0x000000010583a85c -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 489
11 UIKit 0x000000010583a36b -[UIViewController presentViewController:animated:completion:] + 179
12 MyAPP 0x0000000104c7050c _TFC10MyAPP14ViewController5alertfT7messageSS_T_ + 892
13 MyAPP 0x0000000104c71cea _TFFC10MyAPP14ViewController11LoginActionFPs9AnyObject_T_U_FTGSqCSo6NSData_GSqCSo13NSURLResponse_GSqCSo7NSError__T_ + 2250
14 MyAPP 0x0000000104c72197 _TTRXFo_oGSqCSo6NSData_oGSqCSo13NSURLResponse_oGSqCSo7NSError__dT__XFdCb_dGSqS__dGSqS0__dGSqS1___dT__ + 103
15 CFNetwork 0x000000010811fb49 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
16 CFNetwork 0x00000001081320f2 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 302
17 Foundation 0x00000001052db630 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
18 Foundation 0x0000000105216805 -[NSBlockOperation main] + 101
19 Foundation 0x00000001051f9725 -[__NSOperationInternal _start:] + 646
20 Foundation 0x00000001051f9336 __NSOQSchedule_f + 194
21 libdispatch.dylib 0x00000001076953eb _dispatch_client_callout + 8
22 libdispatch.dylib 0x000000010767b82c _dispatch_queue_drain + 2215
23 libdispatch.dylib 0x000000010767ad4d _dispatch_queue_invoke + 601
24 libdispatch.dylib 0x000000010767d996 _dispatch_root_queue_drain + 1420
25 libdispatch.dylib 0x000000010767d405 _dispatch_worker_thread3 + 111
26 libsystem_pthread.dylib 0x00000001079d24de _pthread_wqthread + 1129
27 libsystem_pthread.dylib 0x00000001079d0341 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.
요녀석이 에러의 주범인듯 싶다.
누군가는 이글에서 오류를 해결하기 바라며 일단 오류 메세지 다 올리고
해결은
통신이 끝나고 화면전환이 이루어지는 부분에
dispatch_async(dispatch_get_main_queue()) {
self.LoginSuccess()
}
요로케 해주니 오류 안나더라
그러고 더 작업하는데
로그인 실패시 경고메세지 띄워주는데
또 오류.
그리고 같은 방법으로 해결
------------------------------------------------------------------------------------
dispatch_async(dispatch_get_main_queue())
해결한 후에 저게 뭔지 찾아보니
읽어보니 음 이런거구나
해결해서 기쁨.
'COMPUTER > swift' 카테고리의 다른 글
uitableview 기타등등 기능. (0) | 2016.09.20 |
---|---|
swift tab (0) | 2016.09.19 |
swift 간단 animation 효과 (0) | 2016.08.10 |
swift에서 web을 통해 json 받아오기 (1) | 2016.07.20 |
스위프트 기초 (0) | 2016.02.16 |
swift에서 web을 통해 json 받아오기
다른 방법도 많겠지만 로딩되자마자 콘솔창에 받아오는걸 보고 싶었다.
처음 프로젝트 만들고 나면
ViewController.swift 가 있다.
거기에 이런 부분이 만들어져 있다.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
여기에다가 이렇게 추가하고
override func viewDidLoad() {
let apiURI = NSURL(string: "http://ip.jsontest.com")
let apidata : NSData? = NSData(contentsOfURL: apiURI!)
NSLog("API Result=%@",NSString(data:apidata!,encoding: NSUTF8StringEncoding)!)
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
돌리면 에러난다 에러는 여기서 시키는 대로 하니 해결되더라
http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http
실행시키면
2016-07-20 17:00:09.163 hello[4845:2248555] API Result={"ip": "우리.집.아이.피"}
잘나온다
- 테스트용 json은 http://www.jsontest.com 여기에서 ip받는 부분을 사용했습니다.
'COMPUTER > swift' 카테고리의 다른 글
uitableview 기타등등 기능. (0) | 2016.09.20 |
---|---|
swift tab (0) | 2016.09.19 |
swift 간단 animation 효과 (0) | 2016.08.10 |
API 호출시 UI 멈춤 해결 (1) | 2016.07.28 |
스위프트 기초 (0) | 2016.02.16 |