Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Change Storyboard to Swift
Search
coe
July 15, 2019
Technology
1
600
Change Storyboard to Swift
Change Storyboard to Swift.
coe
July 15, 2019
Tweet
Share
More Decks by coe
See All by coe
すべてのヘルスケアデータを紐解く.pdf
coe
0
2.2k
About HealthKit nutrition
coe
0
350
Kotlin Dynamic type
coe
0
300
iOSDC 2023 Web in tvOS and watchOS
coe
1
560
iOSDC 2023 Push To Talk
coe
1
1.7k
iOSDC手で触れずにアプリを動かす技術
coe
1
1.5k
iOSDC令和時代のXML処理を考える
coe
3
2.2k
iOSDC 2021 Restore
coe
6
1.9k
詳解Storyboard
coe
7
3.5k
Other Decks in Technology
See All in Technology
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
170
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.3k
LINE Developersプロダクト(LIFF/LINE Login)におけるフロントエンド開発
lycorptech_jp
PRO
0
120
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
260
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
160
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
130
MLOps の現場から
asei
6
650
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
110
Qiita埋め込み用スライド
naoki_0531
0
5.1k
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
350
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
BBQ
matthewcrist
85
9.4k
Code Reviewing Like a Champion
maltzj
520
39k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Music & Morning Musume
bryan
46
6.2k
Code Review Best Practice
trishagee
65
17k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Transcript
4UPSZCPBSE͕ ίʔυͰॻ͘ͱ͜͏ͳΔ גࣜձࣾ"NB[JBڧ
ࣗݾհ w ڧʢ5TVZPTIJ)ZVHBʣ w J1IPOF04ʙ w "OESPJE%POVUʙ w UW04ʙ
None
4UPSZCPBSEͰ͢
͚ͲɺίʔυͰ͔ॻ͔ͳ͍ͱ ͍͚ͳ͍࣌ͬͯ͋Γ·͢ΑͶ
ίʔυͰॻ͘
class TmpViewController: UIViewController { let label = UILabel() let button
= UIButton() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white label.text = "Hello World" button.setTitle("button", for: .normal) view.addSubview(label) view.addSubview(button) } }
͜ͷॻ͖ํͩͱɺ 4UPSZCPBSEͰग़དྷͨ ͍ํ͕Ͱ͖ͳ͍
ྫɿҬΛλοϓͯ͠ ใΛදࣔ͢Δ ຊਤΞϓϦͷ߹
/BWJHBUJPO
.PEBM ด͡ΔϘλϯ͕ඞཁʂ
'PSN4IFFU ਖ਼ํܗͳͷͰɺ ԭೄΛผʹͨ͠ σβΠϯʹ͍ͨ͠ʂ
UW04 Ϙλϯʹ57$BQUJPO#VUUPO7JFXΛ͍͍ͨʂ
4UPSZCPBSEͷ߹ w ͜ΕΒશͯͷ7JFXʹରͯ͠ಉ Ұͷ7JFX$POUSPMMFSΛׂΓ ͯΔ͜ͱͰɺ7JFX$POUSPMMFS ॲཧ͚ͩʹઐ೦͢Δ͜ͱ͕ Ͱ͖Δ
͜Ε͕ࠔΔΑίʔυϕʔε w 7JFX$POUSPMMFSʹ7JFXͷσβΠϯΛ͍ͯ͠Δ w ʮσβΠϯ͕ҧ͏͚ͩͰɺΔ͜ͱಉ͡ʯͳ 7JFX$POUSPMMFSΛԿݸ༻ҙͨ͠Γɺϝϯςφϯε͠ ͍͔ͯͳ͍ͱ͍͚ͳ͍ w ͍ͨΜ
4UPSZCPBSEͱಉ༷ͷ͜ͱ͕ Ͱ͖Δ 7JFX$POUSPMMFSΛ࡞Δ
7JFX'BDUPSZύλʔϯ ʢԾশʣ
protocol CodeViewFactoryOwner: class { var titleLabel: UILabel! { get set
} var captionLabel: UILabel! { get set } var imageView: UIImageView! { get set } } class CodeViewFactory: CodeViewFactoryType { func create(owner:CodeViewFactoryOwner) -> UIView { return MyCodeView(owner: owner, frame: .zero) } } class MyCodeView: UIView { init(owner:CodeViewFactoryOwner, frame: CGRect) { super.init(frame: frame) self.backgroundColor = .white let imageView = UIImageView() let titleLabel = UILabel() let captionLabel = UILabel() let button = UIButton(type: .system) button.setTitle("Play", for: .normal) button.addTarget(owner, action: Selector(("clickPlay:")), for: .touchUpInside) self.addSubview(imageView) self.addSubview(titleLabel) self.addSubview(captionLabel) self.addSubview(button) owner.imageView = imageView owner.captionLabel = captionLabel owner.titleLabel = titleLabel } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } }
7JFX'BDUPSZύλʔϯ w ֤छ6*ύʔπΛ࣋ͬͨ0XOFSϓϩτίϧΛ࡞͢Δ w 7JFX'BDUPSZ0XOFSϓϩτίϧΛड͚औΓɺ7JFXͷ࡞ Λߦ͏ w 0XOFSʹ֤छ6*ύʔπΛ͢ w #VUUPOͳͲͷBEE5BSHFUઌʹ0XOFSΛ͢
w μʔΫϞʔυ4J[FDMBTTFTʹରԠ͢Δ߹ɺదͳ6*7JFX ܧঝΫϥεΛ࡞ΓɺUSBJU$PMMFDUJPO%JE$IBOHFͰௐ
class CodeViewController: UIViewController,CodeViewFactoryOwner { @IBOutlet weak var titleLabel: UILabel! @IBOutlet
weak var captionLabel: UILabel! @IBOutlet weak var imageView: UIImageView! private let viewFactory:CodeViewFactoryType? init(viewFactory:CodeViewFactoryType) { self.viewFactory = viewFactory super.init(nibName: nil, bundle: nil) } required init?(coder aDecoder: NSCoder) { viewFactory = nil super.init(coder: aDecoder) } override func loadView() { if let viewFactory = viewFactory { view = viewFactory.create(owner: self) } else { super.loadView() } } @IBAction func clickPlay(_ sender: Any) { } }
7JFX'BDUPSZύλʔϯ 7JFX$POUSPMMFSฤ w 7JFX$POUSPMMFSΛ0XOFSϓϩτίϧʹద߹ͤ͞Δ w 7JFX$POUSPMMFSͰૢ࡞͍ͨ͠7JFXΛXFBLWBSͰϓϩύςΟఆٛ w ͔ͤͬ͘ͳͷͰɺ!*#0VUMFU͚ͭΔ w 7JFX͔Βड͚औΔΞΫγϣϯΛGVODఆٛ
w ͔ͤͬ͘ͳͷͰɺ!*#"DUJPO͚ͭΔ w JOJU࣌ʹҙͷ7JFX'BDUPSZΛड͚औΔ w MPBE7JFX ͰɺTFMGWJFXʹ7JFX'BDUPSZ͔Β࡞ͬͨ7JFXΛׂΓͯΔ
7JFX'BDUPSZύλʔϯ ϝϦοτ w 7JFX$POUSPMMFS͕7JFXͷίʔυͰΒ·ͳ͍ w ذͱ͔JT)JEEFOͱ͔࡞Βͳ͍͍ͯ͘ w 7JFX$POUSPMMFSΛ৭ʑͳγʔϯͰ͍·ΘͤΔ w 7JFX$POUSPMMFS͕ɺͲ͏͍͏7JFXσβΠϯʹͳ͍ͬͯΔ͔ؾʹ͠ͳͯ͘
͍͍ w 6*#VUUPOͩΖ͏ͱɺ57$BQUJPO#VUUPO7JFXͩΖ͏ͱɺΠϯλϥΫ γϣϯΛॲཧ͢Δ͚ͩ w ίʔυϕʔεͱ9JCϕʔεͱ4UPSZCPBSEϕʔεΛ؆୯ʹΓସ͑ΒΕΔ
9JCͷ߹ͷ7JFX'BDUPSZྫ class XibViewFactory: CodeViewFactoryType { func create(owner:CodeViewFactoryOwner) -> UIView {
let nib = UINib(nibName: "CodeXibView", bundle: nil) let xibview = nib.instantiate(withOwner: owner, options: nil) return xibview.first as! UIView } } ˞YJCϑΝΠϧͷ'JMF`TPXOFSͷ$MBTTʹ7JFX$POUSPMMFSΛׂΓ͓ͯͯ͘͜ ͱ
4UPSZCPBSEͷ߹ override func loadView() { if let viewFactory = viewFactory
{ view = viewFactory.create(owner: self) } else { super.loadView()// ←͜͜ } } 4UPSZCPBSEͷ߹ɺWJFX'BDUPSZOJMͳͨΊɺ4UPSZCPBSEͷઃఆͰ6*͕ ߏங͞ΕΔ
·ͱΊ w 4UPSZCPBSEͱಉ͡ײ͡Ͱ7JFX7JFX$POUSPMMFSΛ࡞Γͨ ͍߹ɺ w 7JFX$POUSPMMFSͷ֎͔Β7JFXΛJOKFDU͢Δ w ΧελϜ7JFXɺMPBE7JFX ͰɺTVQFSMPBE7JFX ΛݺͣʹTFMGWJFXʹઃఆ͢Δ
w IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPO VJLJUVJWJFXDPOUSPMMFSMPBEWJFX
if #available(iOS 13.0, *) { self.backgroundColor = .systemBackground } else
{ self.backgroundColor = .white } Ͱɺ͜͏͍͏04ؒͷΘͣΒΘ͠͞Λແͨ͘͢Ίʹɺ 4UPSZCPBSE༗ޮͰ͢Αɻ ʢ4UPSZCPBSE্Ͱ4ZTUFN#BDLHMPVE$PMPSΛઃఆ͢Δ͚ͩͰ શͯͷ04ʹରԠͰ͖Δʣ
גࣜձࣾ"NB[JBͰ ΤϯδχΞΛืू͍ͯ͠·͢ IUUQTBNB[JBDPKQDBSFFS