Submit Search
よこへな3 15発表資料 最近ViewController をどんな感じで書いているか
0 likes
1,311 views
Yuichiro Suzuki
1 of 8
Download now
Download to read offline
1
2
3
4
5
6
7
8
More Related Content
PDF
Auto Layout Tips
Kosuke Usami
PDF
JavaScript + CSS3を活用して スマートフォンサイト/アプリに 動きを付けてみよう
Hiroaki Wakamatsu
PDF
introduction to Marionette.js (jscafe14)
Ryuma Tsukano
PDF
XIBで作ったカスタムセルの扱い方
Satoshi Anai
KEY
HTML5で作るスマホブラウザゲーム
Takumi Ohashi
PDF
実践Backbone.Marionette 現場の悩みと解決まで
Ryuma Tsukano
PDF
レスポンシブWebデザイン【発展編】
Yasuhito Yabe
PDF
公式page改ざんで学ぶjQuery入門 (jscafe7)
Ryuma Tsukano
Auto Layout Tips
Kosuke Usami
JavaScript + CSS3を活用して スマートフォンサイト/アプリに 動きを付けてみよう
Hiroaki Wakamatsu
introduction to Marionette.js (jscafe14)
Ryuma Tsukano
XIBで作ったカスタムセルの扱い方
Satoshi Anai
HTML5で作るスマホブラウザゲーム
Takumi Ohashi
実践Backbone.Marionette 現場の悩みと解決まで
Ryuma Tsukano
レスポンシブWebデザイン【発展編】
Yasuhito Yabe
公式page改ざんで学ぶjQuery入門 (jscafe7)
Ryuma Tsukano
What's hot
(12)
PDF
Enhancements with 3D Touch
Satoshi Ohki
PDF
絶望しない! コミケ
Kazutoshi Kashimoto
PPTX
jQueryで気をつけてほしいこと
良太 増子
PDF
Jsのビルド環境
fourside
PDF
Study Intro Backbone
Gensei Kawasaki
PDF
Apple watch対応アプリのポイントや基本実装・連携tips
Fumiya Sakai
PPTX
Effective flutter
小川 昌吾
PDF
Alt01-LT
Yuta Hiroto
PPT
YUI
Tatsuya Sasaki
PDF
JavaScriptと共に歩いて行く決意をした君へ
Muyuu Fujita
PDF
SQLアンチパターン読書会 15章 ランダムセレクション 説明資料
Nao Yamamoto
PPTX
Excel 方眼紙撲滅委員会 活動報告 2012.11 #odstudy
Takeshi Komiya
Enhancements with 3D Touch
Satoshi Ohki
絶望しない! コミケ
Kazutoshi Kashimoto
jQueryで気をつけてほしいこと
良太 増子
Jsのビルド環境
fourside
Study Intro Backbone
Gensei Kawasaki
Apple watch対応アプリのポイントや基本実装・連携tips
Fumiya Sakai
Effective flutter
小川 昌吾
Alt01-LT
Yuta Hiroto
YUI
Tatsuya Sasaki
JavaScriptと共に歩いて行く決意をした君へ
Muyuu Fujita
SQLアンチパターン読書会 15章 ランダムセレクション 説明資料
Nao Yamamoto
Excel 方眼紙撲滅委員会 活動報告 2012.11 #odstudy
Takeshi Komiya
Ad
Viewers also liked
(20)
PDF
Alvaro Fides - Use of hierarchical model-view-controller architecture for use...
WTHS
PPT
Wellington Residences - Lisa
nikatherez
PDF
Paper María Iglesia - CEIB: A R&D services in bioimaging oriented to integrat...
WTHS
PDF
Registry of Course Trainers For 2013
sohainstitute
PDF
Paper Florencio Cano - Patient data security in a wireless and mobile world
WTHS
PPT
The Maori :background
MRINCON002
PDF
Beni Gómez - APTIC a knowledge repository for parents and caregivers of chil...
WTHS
PDF
عامر عرموش
Amer Armoush
PDF
Basic html
dand_01
PDF
Alejandro Gonzalez - An iPhone-based application for promoting type 2 diabeti...
WTHS
PPTX
Presentation finale3 sfr2011
larhumato
PPT
Audience research
sherieallen
PDF
Mercedes Serrano - Guía metabólica: empowerment through health 2.0 tools in ...
WTHS
DOC
Chapter13
MRINCON002
PPTX
Cintai pangan lokal
Yayasan Perempuan Kaisa Indonesia
PPTX
Question 2 - Evaluation
FayBurmingham
PDF
Manuel Armañones - Mesa redonda: Health 2.0
WTHS
ODP
New Year’s Eve in New York City
rogerfranquesa
PPTX
Buildings by jihad awad
Jihad Awad
PPTX
Professional Innovator Development
danaclarke
Alvaro Fides - Use of hierarchical model-view-controller architecture for use...
WTHS
Wellington Residences - Lisa
nikatherez
Paper María Iglesia - CEIB: A R&D services in bioimaging oriented to integrat...
WTHS
Registry of Course Trainers For 2013
sohainstitute
Paper Florencio Cano - Patient data security in a wireless and mobile world
WTHS
The Maori :background
MRINCON002
Beni Gómez - APTIC a knowledge repository for parents and caregivers of chil...
WTHS
عامر عرموش
Amer Armoush
Basic html
dand_01
Alejandro Gonzalez - An iPhone-based application for promoting type 2 diabeti...
WTHS
Presentation finale3 sfr2011
larhumato
Audience research
sherieallen
Mercedes Serrano - Guía metabólica: empowerment through health 2.0 tools in ...
WTHS
Chapter13
MRINCON002
Cintai pangan lokal
Yayasan Perempuan Kaisa Indonesia
Question 2 - Evaluation
FayBurmingham
Manuel Armañones - Mesa redonda: Health 2.0
WTHS
New Year’s Eve in New York City
rogerfranquesa
Buildings by jihad awad
Jihad Awad
Professional Innovator Development
danaclarke
Ad
よこへな3 15発表資料 最近ViewController をどんな感じで書いているか
1.
最近ViewControllerを どんな風に書いているか @u16suzu http://u16suzu.hatenablog.com/
2.
自己紹介 • @u16suzu • iOSを仕事で初めて1年と2ヶ月くらい •
Railsもやります. プログラミング大好き!
3.
今日の内容 • xib, story
boardを使わないでコードだけで iOSを 書くときに,どういう風にViewControllerをかいて いるか • 主にビューの描画部分について
4.
- (void)viewDidLoad{ [super viewDidLoad]; ! UIButton*btn
= [UIButton buttonWithType:UIButtonTypeSystem]; btn.frame = CGRectMake(100, 100, 100, 50); [btn setTitle:@"Button" forState:UIControlStateNormal]; [btn sizeToFit]; [self.view addSubview:btn]; UILabel*l = [[UILabel alloc]initWithFrame:CGRectMake(100, 150, 100, 50)]; l.text = @"label"; [self.view addSubview:l]; } 昔 viewDidLoad にコントロールの初期化と位置指定 のコードが全て書いてある
5.
今 コントロールの初期化と位置指定を分けている @interface ViewController () @property
(nonatomic) UIView*titleView; @property (nonatomic) CustomView*customView; @end ! @implementation ViewController - (void)loadView{ [super loadView]; [self.view addSubview:self.titleView]; [self.view addSubview:self.customView]; } ! - (void)viewDidLayoutSubviews{ [super viewDidLayoutSubviews]; CGRect titleViewFrame = CGRectMake(50, 50, 50, 50); self.titleView.frame = titleViewFrame; CGRect customViewFrame = CGRectMake(50, 100, 300, 100); self.customView.frame = customViewFrame; } ! #pragma mark - Views ! - (UIView*)titleView{ if(!_titleView){ _titleView = [UIView new]; _titleView.backgroundColor = [UIColor redColor]; } return _titleView; } ! - (CustomView*)customView{ if(!_customView){ _customView = [CustomView new]; } return _customView; } ! @end プロパティで宣言 アクセッサで初期化 viewDidLayoutSubviews で位置指定 loadViewでaddSubview
6.
改善ポイント • コントロールの位置の変更が容易 • ソースコードが読みやすくなった •
カスタムビューに分割しやすい
7.
- (id)initWithFrame:(CGRect)frame{ self =
[super initWithFrame:frame]; if (self) { [self addSubview:self.firstButton]; } return self; } ! #pragma - Views ! - (void)layoutSubviews{ [super layoutSubviews]; [self.firstButton sizeToFit]; CGRect frame = CGRectMake(0, 0, 60, 30); self.firstButton.frame = frame; } ! - (UIButton*)firstButton{ if(!_firstButton){ _firstButton = [UIButton buttonWithType:UIButtonTypeSystem]; [_firstButton setTitle:@"firstButton" forState:UIControlStateNormal]; } return _firstButton; } 今のカスタムビュー layoutSubviewsで位置指定 initWithFrameで addSubview あとは VCと同じ
8.
以上です!
Download