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
2k
About HealthKit nutrition
coe
0
340
Kotlin Dynamic type
coe
0
280
iOSDC 2023 Web in tvOS and watchOS
coe
1
530
iOSDC 2023 Push To Talk
coe
1
1.6k
iOSDC手で触れずにアプリを動かす技術
coe
1
1.4k
iOSDC令和時代のXML処理を考える
coe
3
2.1k
iOSDC 2021 Restore
coe
6
1.8k
詳解Storyboard
coe
7
3.4k
Other Decks in Technology
See All in Technology
独自ツール開発でスタジオ撮影をDX!「VLS(Virtual LED Studio)」 / dx-studio-vls
cyberagentdevelopers
PRO
1
180
LeSSに潜む「隠れWF病」とその処方箋
lycorptech_jp
PRO
2
120
なんで、私がAWS Heroに!? 〜社外の広い世界に一歩踏み出そう〜
minorun365
PRO
6
1.1k
バクラクにおける可観測性向上の取り組み
yuu26
3
420
10分でわかるfreeeのQA
freee
1
3.4k
Automated Promptingを目指すその前に / Before we can aim for Automated Prompting
rkaga
0
110
【若手エンジニア応援LT会】AWS Security Hubの活用に苦労した話
kazushi_ohata
0
170
신뢰할 수 있는 AI 검색 엔진을 만들기 위한 Liner의 여정
huffon
0
340
ガバメントクラウド先行事業中間報告を読み解く
sugiim
1
1.3k
Autify Company Deck
autifyhq
1
39k
visionOSでの空間表現実装とImmersive Video表示について / ai-immersive-visionos
cyberagentdevelopers
PRO
1
110
サイバーエージェントにおける生成AIのリスキリング施策の取り組み / cyber-ai-reskilling
cyberagentdevelopers
PRO
2
200
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
32
1.8k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Writing Fast Ruby
sferik
626
61k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
RailsConf 2023
tenderlove
29
880
Embracing the Ebb and Flow
colly
84
4.4k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
Into the Great Unknown - MozCon
thekraken
31
1.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
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