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
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
Taming you application's environments
salaboy
0
190
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
230
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
180
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
890
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
760
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
140
Engineer Career Talk
lycorp_recruit_jp
0
190
強いチームと開発生産性
onk
PRO
35
11k
Featured
See All Featured
Designing Experiences People Love
moore
138
23k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Speed Design
sergeychernyshev
25
620
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
The World Runs on Bad Software
bkeepers
PRO
65
11k
GitHub's CSS Performance
jonrohan
1030
460k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
4 Signs Your Business is Dying
shpigford
180
21k
Typedesign – Prime Four
hannesfritz
40
2.4k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Making Projects Easy
brettharned
115
5.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
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