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.1k
About HealthKit nutrition
coe
0
340
Kotlin Dynamic type
coe
0
290
iOSDC 2023 Web in tvOS and watchOS
coe
1
540
iOSDC 2023 Push To Talk
coe
1
1.7k
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
Taming you application's environments
salaboy
0
180
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
200
The Rise of LLMOps
asei
7
1.4k
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
AIチャットボット開発への生成AI活用
ryomrt
0
170
SSMRunbook作成の勘所_20241120
koichiotomo
2
130
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
590
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.6k
Lambdaと地方とコミュニティ
miu_crescent
2
370
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
980
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
65
11k
Happy Clients
brianwarren
98
6.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Site-Speed That Sticks
csswizardry
0
23
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Automating Front-end Workflow
addyosmani
1366
200k
Unsuck your backbone
ammeep
668
57k
Designing the Hi-DPI Web
ddemaree
280
34k
Speed Design
sergeychernyshev
24
610
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