Slide 1

Slide 1 text

UICollectionViewを使って 商品一覧を改善する (BUYMAアプリ) 株式会社エニグモ シニアエンジニア 大川 琢

Slide 2

Slide 2 text

BUYMA(バイマ)は、世界105カ国に在住する 約5万人のパーソナルショッパーから 世界中の魅力的な商品をお得に購入できる、 会員数170万人のこれまでにない 新しいソーシャル・ショッピング・サイトです。 BUYMAとは?

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

BUYMAアプリ作った経緯 ● 近年のスマートフォンのアクセス率の増加 ● 中でも若年層の割合が増加 ● アプリを作ってほしいというユーザーからの要望 ● オーガニック流入以外の会員獲得

Slide 5

Slide 5 text

BUYMAアプリのコンセプト ● 趣向にあった商品との出会い ● 好きな商品群を気軽にチェックできる ● 旬な商品を把握できる ● 商品をリアルに感じさせるUI

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

よい反響もありつつ

Slide 8

Slide 8 text

リリース後に頂いた改善要望の内訳

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

要約 画像でかすぎ!!

Slide 14

Slide 14 text

とりあえず画像が大きいというのもあるが、

Slide 15

Slide 15 text

BUYMA固有の課題

Slide 16

Slide 16 text

同一モデルの商品

Slide 17

Slide 17 text

Webサイト(スマホ用)

Slide 18

Slide 18 text

Webサイト(スマホ用) 商品自体は同じ!

Slide 19

Slide 19 text

Webサイト(スマホ用) スクロール疲れ

Slide 20

Slide 20 text

アプリになると

Slide 21

Slide 21 text

よりしんどくなる感 じ。。

Slide 22

Slide 22 text

もうちょっと一覧でみたい。 とはいえ、大きな画像でもみたい。

Slide 23

Slide 23 text

改善スプリント開始

Slide 24

Slide 24 text

テーブルビュー グリッドビュー 検索結果一覧で、二種類のビューで見れるようにする。

Slide 25

Slide 25 text

スクロールポジション(どこまで見たか)の 保持、割と重要!

Slide 26

Slide 26 text

実装パターン

Slide 27

Slide 27 text

UITableView UICollectionView

Slide 28

Slide 28 text

UITableView UICollectionView フェードインで遷移 contentOffset同期

Slide 29

Slide 29 text

DEMO

Slide 30

Slide 30 text

問題はないが、、、

Slide 31

Slide 31 text

問題はないが、、、 アイテムがどこに行ったかという、 キュー(手がかかり)がない

Slide 32

Slide 32 text

問題はないが、、、 アイテムがどこに行ったかという、 キュー(手がかかり)がない 2つViewを保持することへの(プログラ マ的)抵抗感

Slide 33

Slide 33 text

UICollectionView

Slide 34

Slide 34 text

● iOS6で導入されたUIKitのクラス ● 簡単に言うと、レイアウトをカスタマイ ズできるUITableView

Slide 35

Slide 35 text

応用例

Slide 36

Slide 36 text

objc.io - Custom CollectionView Layouts http://www.objc.io/issue-3/collection-view-layouts.html

Slide 37

Slide 37 text

iOS6-Playground https://github.com/brianpartridge/iOS6-Playground

Slide 38

Slide 38 text

Matt Thompson

Slide 39

Slide 39 text

今回は規則的に(リニアに)セルを並べ るだけなのでもっと地味に使う

Slide 40

Slide 40 text

UITableView UICollectionView

Slide 41

Slide 41 text

UICollectionFlowLayout UICollectionFlowLayout UICollectionView CollectionViewLay out

Slide 42

Slide 42 text

UICollectionFlowLayout UICollectionFlowLayout UICollectionView CollectionViewLay out プロパティを変更するだけで レイアウトが変更できる -(void)setCollectionViewLayout animated:(BOOL)animated

Slide 43

Slide 43 text

DEMO

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

ハマりポイント

Slide 48

Slide 48 text

セル自体のレイアウトは変更してくれる けど、グリッド↔テーブルでセルの変更 はしてくれない。

Slide 49

Slide 49 text

テーブルビュー グリッドビュー TableLayoutCell GridLayoutCell

Slide 50

Slide 50 text

セル自体のレイアウトは変更してくれる けど、グリッド↔テーブルでセルの変更 はしてくれない。 無理やりreloadDataすると、アニメーションがゴ ニョっとしてしまう。。。

Slide 51

Slide 51 text

じゃあ、ひとつのセルで両方のレイアウト に使用するか。。。

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

ヘッダーはなしで ボタンは縦に配置 価格のみ表示

Slide 54

Slide 54 text

AutoLayoutだけでは厳しい

Slide 55

Slide 55 text

レイアウト切替時に、セル内部もアニ メーションしたい。が、

Slide 56

Slide 56 text

セル自体の変更やアニメーションを行う delegateやサブクラスはない...

Slide 57

Slide 57 text

もう一回よく考えてみる

Slide 58

Slide 58 text

- (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)animated

Slide 59

Slide 59 text

- (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)YES

Slide 60

Slide 60 text

UICollectionFlowLayout UICollectionFlowLayout UICollectionView - (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)YES frame( 10,10, 140, 140) frame( 20,520, 320,420)

Slide 61

Slide 61 text

UICollectionFlowLayout UICollectionFlowLayout UICollectionView - (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)YES frame( 10,10, 140, 140) frame( 20,520, 320,420) 2つのframe間をア ニメーション

Slide 62

Slide 62 text

UICollectionFlowLayout UICollectionFlowLayout UICollectionView - (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)YES frame( 10,10, 140, 140) center alpha hidden translate3D frame( 20,520, 320,420) カスタムのレイアウトを組む 時のdelegateメソッドで返す オブジェクト UICollectionViewLayoutAttributes

Slide 63

Slide 63 text

- (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)NO

Slide 64

Slide 64 text

UICollectionFlowLayout UICollectionFlowLayout UICollectionView - (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)YES frame( 10,10, 140, 140) frame( 20,520, 320,420) 一気に切り替わる

Slide 65

Slide 65 text

UICollectionFlowLayout UICollectionFlowLayout UICollectionView - (void)setCollectionViewLayout:(UICollectionViewLayout *)layout animated:(BOOL)YES frame( 10,10, 140, 140) frame( 20,520, 320,420) frameをセットしてる だけっぽい。 cell.frame = CGRectMake(10,10,140,140)

Slide 66

Slide 66 text

frameの変更をアニメーション?

Slide 67

Slide 67 text

古くて新しいUIView animation

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

DEMO

Slide 70

Slide 70 text

おまけ

Slide 71

Slide 71 text

Revealとてもよい

Slide 72

Slide 72 text

まとめ

Slide 73

Slide 73 text

● APIとの戦い → とりあえずWWDCセッションビデオみるの 重要。 ● 困ったら基本に戻る/発想変えてみる(なんとなくフレーム ワーク内の動きを想像してみる) ● 今回は試してないけどViewController Transition API(iOS 7)でもいけるかも ● 日頃の研鑽大事

Slide 74

Slide 74 text

エニグモでは一緒にBUYMAを盛り上げてくれるエ ンジニアを募集中です!

Slide 75

Slide 75 text

ご清聴ありがとうございました!!