๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐ŸŽ iOS/iOS Application

(26)
[iOS/Swift] ์ฝ”๋“œ๋กœ ์ง„๋™(Vibrate) ์šธ๋ฆฌ๊ธฐ, ํšจ๊ณผ์Œ ๋„ฃ๊ธฐ - AudioServicesPlaySystemSound AudioServicesPlaySystemSound ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋กœ ์ง„๋™(Vibrate) ์šธ๋ฆฌ๊ธฐ ๐Ÿ’ก 1. AVFoundation์„ import import AVFoundation AVFoundation : ์‹œ์ฒญ๊ฐ assets ์ž‘์—…, device์นด๋ฉ”๋ผ ์ œ์–ด, ์˜ค๋””์˜ค ์ฒ˜๋ฆฌ ๋ฐ ์‹œ์Šคํ…œ ์˜ค๋””์˜ค์™€์˜ ์ƒํ˜ธ์ž‘์šฉ ๊ตฌ์„ฑ ๐Ÿ’ก 2. AudioServicesPlaySystemSound ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋กœ ์ง„๋™ ๊ตฌํ˜„ ๊ตฌํ˜„ํ•˜๊ณ  ์‹ถ์€ ๊ณณ์— ์•„๋ž˜ ์ฝ”๋“œ ์ž‘์„ฑ AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); *์ง„๋™, ํšจ๊ณผ์Œ ๋ฐœ์ƒ ํ•จ์ˆ˜ AudioServicesPlaySystemSound func AudioServicesPlaySystemSound(_ inSystemSoundID: SystemS..
[iOS/Swift] @IBInspectable, @IBDesignable ์‚ฌ์šฉํ•˜๊ธฐ - UIButton ์ปค์Šคํ…€ํ•˜๊ธฐ, UITextField ์ปค์Šคํ…€ํ•˜๊ธฐ @IBInspectable, @IBDesignable ์•Œ์•„๋ณด๊ณ  ์‚ฌ์šฉํ•˜๊ธฐ - UIButton ์ปค์Šคํ…€ํ•˜๊ธฐ, UITextField ์ปค์Šคํ…€ํ•˜๊ธฐ - UIButton ํ…Œ๋‘๋ฆฌ ๋งŒ๋“ค๊ธฐ - UITextField์— ์ด๋ฏธ์ง€ ์ถ”๊ฐ€ํ•˜๊ธฐ ๐Ÿ’ก1. IB ? @IBOutlet, @IBAction, @IBInspectable, @IBDesignable์™€ ๊ฐ™์ด IB๋กœ ์‹œ์ž‘ํ•˜๋Š” Attribute๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค. Xcode์—์„œ IB๋Š” Interface Builder๋ฅผ ์˜๋ฏธํ•˜๊ณ  ์Šคํ† ๋ฆฌ๋ณด๋“œ(Storyboard)๋ฅผ ๋งํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ, ์Šคํ† ๋ฆฌ๋ณด๋“œ์™€ ์ฝ”๋“œ๋ฅผ ์—ฐ๊ฒฐ์‹œํ‚ฌ ๋•Œ, ์šฐ๋ฆฌ๋Š” IB๋กœ ์‹œ์ž‘ํ•˜๋Š” Attribute๋“ค์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ์นœ๊ตฌ๋“ค์„ ์‚ฌ์šฉํ•˜์—ฌ ์Šคํ† ๋ฆฌ๋ณด๋“œ์—์„œ ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋žœ๋”๋ง ํ•ด๋ด…์‹œ๋‹ค.๐Ÿ˜Š ๐Ÿ’ก2. @IBInspectable ? @IBInspectab..
[iOS] ์ฝ”๋“œ๋กœ ํ™”๋ฉด ๋ฐ๊ธฐ ์กฐ์ ˆ, ์ž๋™ ์ž ๊ธˆ ํ™œ์„ฑํ™”/๋น„ํ™œ์„ฑํ™” (์ ˆ์ „๋ชจ๋“œ) ํ•˜๊ธฐ(Swift, Objective-c) iOS ์ฝ”๋“œ๋กœ ํ™”๋ฉด ๋ฐ๊ธฐ ์กฐ์ ˆ, ์ž๋™ ์ž ๊ธˆ ํ™œ์„ฑํ™”/๋น„ํ™œ์„ฑํ™” (์ ˆ์ „๋ชจ๋“œ) ํ•˜๊ธฐ ์˜ค๋Š˜์€ ์•„์ดํฐ์˜ ํ™”๋ฉด์„ ์ œ์–ดํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋จผ์ €, ์š”์ฆ˜๊ฐ™์ด QR์„ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” ๋‚ ๋„ ์—†์„๊ฑฐ์—์š”.... ํ™”๋ฉด์ด ์–ด๋‘์šฐ๋ฉด QR์ธ์‹์ด ์ž˜ ์•ˆ๋˜๋ฏ€๋กœ QR ์‹คํ–‰์‹œ ํ™”๋ฉด์ด ์ตœ๋Œ€๋กœ ๋ฐ๋„๋ก ์ œ์–ดํ•˜๋Š” ๋กœ์ง์ด ํ•„์š”ํ•˜๊ฒ ์ฃ ~? ์ตœ๋Œ€ ๋ฐ๊ธฐ, ๋ฐ๊ธฐ๋ฅผ ์กฐ์ ˆํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์ ˆ์ „๋ชจ๋“œ๋ฅผ ๋น„ํ™œ์„ฑํ™”์‹œํ‚ค๋ฉด ํ™”๋ฉด์ด ์ž๋™์œผ๋กœ ์ž ๊ธˆ ๋˜์ง€ ์•Š๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. โœ”๏ธ 1. ํ™”๋ฉด ๋ฐ๊ธฐ ์กฐ์ ˆํ•˜๊ธฐ UIScreen.main.brightness ๋กœ ํ™”๋ฉด ๋ฐ๊ธฐ๋ฅผ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค. ์ด๋•Œ, birghtness๋Š” floatํ˜•์œผ๋กœ 0.0~1.0์˜ ๊ฐ’์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค. ์ตœ๋Œ€์˜ ๋ฐ๊ธฐ๋ฅผ ํ•˜๋ ค๋ฉด 1.0์œผ๋กœ ์„ค์ •ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ํ˜„์žฌ ๋ฐ๊ธฐ๋ฅผ ๋ฐ›์•„์™€ ์ตœ๋Œ€(1.0)์ด ์•„๋‹Œ..
[iOS] URL Scheme ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค๋ฅธ ์•ฑ๊ณผ ํ†ต์‹ ํ•˜๊ธฐ URL Scheme๋กœ ๋‹ค๋ฅธ ์•ฑ๊ณผ ํ†ต์‹ ํ•ด๋ณด์ž iOS์—์„œ๋Š” URL Scheme์„ ํ†ตํ•ด ๋‹ค๋ฅธ ์•ฑ๊ณผ ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค! URL Scheme์„ ํ†ตํ•ด ๋‹ค๋ฅธ ์•ฑ์˜ ์‹คํ–‰์„ ์š”์ฒญํ•˜๊ฑฐ๋‚˜ ๊ฐ„๋‹จํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์ „ํ™”ํ•˜๊ณ  ์‹ถ์€ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋ฐ”๋กœ ์ „ํ™” ์–ดํ”Œ๋กœ ์—ฐ๊ฒฐ๋˜์–ด ์ „ํ™”๋ฅผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. *์‹ค์ œ ๊ธฐ๊ธฐ๋กœ ํ…Œ์ŠคํŠธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ์—์„œ๋Š” sms๋งŒ ๊ฐ€๋Šฅ! ๐Ÿ”ฅ iOS Built-in URL Scheme iOS๋Š” ๊ธฐ๋ณธ์œผ๋กœ ์„ค์น˜๋œ ๋ฉ”์ผ, ์ „ํ™”, ๋ฉ”์‹œ์ง€ ์ง€๋„ ์•ฑ๊ณผ ํ†ต์‹ ํ•  ์ˆ˜ ์žˆ๋Š” ๋‚ด์žฅ URL Scheme์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ์ •๋ณด์™€ ์‚ฌ์šฉ๋ฒ•์€ ์•„๋ž˜ ์‚ฌ์ดํŠธ์—์„œ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜Š About Apple URL Schemes About Apple URL Schemes This document describes..
[Xcode] iOS ๋ฒ„์ „๋ณ„ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ ์„ค์น˜ ๋ฐ ์ถ”๊ฐ€ํ•˜๊ธฐ Xcode ์„ค์น˜ ์‹œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ตœ์‹  iOS ๋ฒ„์ „์œผ๋กœ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ์ „ ๋ฒ„์ „ ๋“ฑ ๋‹ค๋ฅธ ๋ฒ„์ „์˜ iOS๋กœ ํ…Œ์ŠคํŠธํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ iOS ๋ฒ„์ „๋ณ„ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ ์„ค์น˜ ๋ฐ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฒ•์„ ์•Œ๋ ค๋“œ๋ฆฝ๋‹ˆ๋‹ค. ๐Ÿ’ก ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ iOS ๋ฒ„์ „๋ณ„ ์„ค์น˜ 1. Xcode > Preferences 2. Components ๋ฉ”๋‰ด์—์„œ ํ•„์š”ํ•œ iOS ๋ฒ„์ „์˜ ๋‹ค์šด๋กœ๋“œ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‹ค์šด๋กœ๋“œ๊ฐ€ ์ง„ํ–‰๋ฉ๋‹ˆ๋‹ค. ๋‹ค์šด๋กœ๋“œ๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ํŒŒ๋ž€์ƒ‰ ์ฒดํฌ๋ฐ•์Šค๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ๐Ÿ’ก ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ iOS ๋ฒ„์ „ ์ˆ˜์ • 1. Window > Devices and Simulators 2. ์ขŒ์ธก ํ•˜๋‹จ์˜ + ๋ฒ„ํŠผ์„ ํด๋ฆญ 3. ๋‹ค์šด ๋ฐ›์€ iOS ๋ฒ„์ „์œผ๋กœ ์ƒˆ๋กœ์šด ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ๋ฅผ ํด๋ฆญํ•ด์ค๋‹ˆ๋‹ค. ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ ์ด๋ฆ„, Device Type๊ณผ ํ•จ๊ป˜ ๋‹ค์šด๋กœ๋“œํ•œ iOS ๋ฒ„์ „์œผ๋กœ ์„ค์ • ํ›„..
[iOS] SceneDelegate ์‚ญ์ œํ•˜๊ธฐ SceneDelegate ์‚ญ์ œํ•˜๋Š” ๋ฒ•์„ ์•Œ์•„๋ณด์ž SceneDelegate๋Š” iOS 13๋ถ€ํ„ฐ ์ƒˆ๋กœ ์ถ”๊ฐ€๋˜์–ด Xcode11๋ถ€ํ„ฐ SceneDelegate๊ฐ€ ๊ธฐ๋ณธ iOS ์•ฑ ํ”„๋กœ์ ํŠธ ํ…œํ”Œ๋ฆฟ์œผ๋กœ ์ž๋™์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ƒฅ ์ง€์šฐ๊ณ  ๋นŒ๋“œํ•˜๋ฉด ๊ฒ€์€ ํ™”๋ฉด์ด ๋‚˜์˜ค๊ธฐ ๋•Œ๋ฌธ์—, ๋‹ค์Œ ๊ณผ์ •์„ ๋”ฐ๋ฅด๋ฉด ํ™•.์‹ค.ํ•˜.๊ฒŒ. ์‚ญ์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค๐Ÿ‘ป 1. Info.plist์—์„œ Application Scene Manifest ์‚ญ์ œ ์‚ญ์ œ ์•ˆํ•˜๋Š” ๊ฒฝ์šฐ ์•„๋ž˜ ์—๋Ÿฌ๋ฐœ์ƒ >> 13:23:49.218883+0900 FunctionList_Objc[45720:3662506] [SceneConfiguration] Info.plist configuration "Default Configuration" for UIWindowSceneSessionRoleApplic..
[iOS] ์•Œ๊ณ ๋ฆฌ์ฆ˜, ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ค€๋น„ํ•˜๊ธฐ - Command Line Tool, LeadLine, Split, Components, map, print ์‚ฌ์šฉํ•˜๊ธฐ Swift๋กœ ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ ์ค€๋น„, ์„ธํŒ…ํ•˜๊ธฐ Swift ์ž…๋ ฅํ•˜๊ธฐ Swift๋กœ ์ฝ”ํ…Œ๋ฅผ ์ค€๋น„ํ•˜๋ ค๊ณ  ํ•˜๋‹ˆ! ์–ด๋–ป๊ฒŒ ์ž…๋ ฅ์„ ๋ฐ›์•„์„œ ์ฒ˜๋ฆฌํ•˜์ง€...? Swift๋กœ ์ž…๋ ฅ์„ ๋ฐ›๊ธฐ ์œ„ํ•ด์„  project ์ƒ์„ฑ์‹œ, playground, app์ด ์•„๋‹Œ ์ƒˆ๋กœ์šด ํƒฌํ”Œ๋ฆฟ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค! ์ฝ”ํ…Œ๋ฅผ ์œ„ํ•œ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ๋ฒ•, Swift์—์„œ ์ž…์ถœ๋ ฅ๋ฐ›๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ๋ ค๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค! ๐Ÿ‘ป 1. ํ”„๋กœ์ ํŠธ ๋งŒ๋“ค๊ธฐ ๋จผ์ €, playground๋Š” sandbox์ด๊ธฐ ๋•Œ๋ฌธ์— commandline input์— ์ ‘๊ทผํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค! (*์ƒŒ๋“œ๋ฐ•์Šค(sandbox) : ์™ธ๋ถ€๋กœ๋ถ€ํ„ฐ ๋“ค์–ด์˜จ ํ”„๋กœ๊ทธ๋žจ์ด ๋ณดํ˜ธ๋œ ์˜์—ญ์—์„œ ๋™์ž‘ํ•ด ์‹œ์Šคํ…œ์ด ๋ถ€์ •ํ•˜๊ฒŒ ์กฐ์ž‘๋˜๋Š” ๊ฒƒ์„ ๋ง‰๋Š” ๋ณด์•ˆ ํ˜•ํƒœ) ๋”ฐ๋ผ์„œ, project๋ฅผ ์ƒ์„ฑ ์‹œ ํ…œํ”Œ๋ฆฟ์„ Command Line Tool๋กœ ์„ ํƒํ•˜์—ฌ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค! xc..
[iOS] respondsToSelector, ์˜ต์…”๋„ ์ฒด์ด๋‹ ์‚ฌ์šฉํ•˜์—ฌ ๋ธ๋ฆฌ๊ฒŒ์ดํŠธ์˜ ์„ ํƒ์  ๋ฉ”์†Œ๋“œ(optional method) ๊ตฌํ˜„ ์—ฌ๋ถ€ ํ™•์ธํ•˜๊ธฐ (in Swift, Objective-C) ๋ธ๋ฆฌ๊ฒŒ์ดํŠธ์˜ ์„ ํƒ์  ๋ฉ”์†Œ๋“œ(optional method) ๊ตฌํ˜„ ์—ฌ๋ถ€ ํ™•์ธํ•ด๋ณด์ž Swift์™€ Objc์˜ ํ”„๋กœํ† ์ฝœ์—์„œ ๋ฉ”์†Œ๋“œ๋Š” ํ•„์ˆ˜, ์„ ํƒ์  ๋ฉ”์†Œ๋“œ๋กœ ๊ตฌํ˜„ ๊ฐ€๋Šฅํ•˜๋‹ค. ์„ ํƒ์  ๋ฉ”์†Œ๋“œ(optional method)๋ฅผ ํ˜ธ์ถœํ•˜๊ธฐ ์ „, ๋ธ๋ฆฌ๊ฒŒ์ดํŠธ๊ฐ€ ํ˜ธ์ถœํ•˜๋Š” ์„ ํƒ์ž์— ์‘๋‹ตํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ๋‚ด์„ฑ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.!!! ๊ตฌํ˜„ํ•˜์ง€ ์•Š์€ ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ ์‹œ null๊ฐ’์„ ๋ณด๋‚ด Crash๊ฐ€ ๋‚˜๊ธฐ ๋•Œ๋ฌธ!!! ๐Ÿ˜ญ ๋”ฐ๋ผ์„œ, ๋ฐ˜๋“œ์‹œ ํ”„๋กœํ† ์ฝœ์˜ ์˜ต์…”๋„ ๋ฉ”์†Œ๋“œ ์‚ฌ์šฉ ์ „ ๊ตฌํ˜„ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜๋Š” ์ ˆ์ฐจ๋ฅผ ์ˆ˜ํ–‰ํ•ด์•ผํ•œ๋‹ค. ๐Ÿ‘๐Ÿป โ–ถ Objective-C ํ”„๋กœํ† ์ฝœ ๋ฉ”์†Œ๋“œ ๊ตฌํ˜„ ์—ฌ๋ถ€ ํ™•์ธํ•˜๊ธฐ ์ผ๋‹จ ObjC ์—์„œ ํ”„๋กœํ† ์ฝœ์€ ์•„๋ž˜ ์ฝ”๋“œ์™€ ๊ฐ™์ด ํ‚ค์›Œ๋“œ๊ฐ€ ์—†๋Š” ๋ฉ”์†Œ๋“œ๋Š” ๋ชจ๋‘ ํ•„์ˆ˜์ ์œผ๋กœ ๊ตฌํ˜„ํ•ด์•ผ ํ•˜๋Š” ๋ฉ”์†Œ๋“œ, @optional ํ‚ค์›Œ๋“œ ๋‹ค์Œ์— ๋‚˜์˜ค๋Š” ๋ฉ”์†Œ๋“œ๋“ค..

๋ฐ˜์‘ํ˜•