LoginSignup
3
2

More than 5 years have passed since last update.

PreferenceLoaderでカスタムセル(タイトル)を作る

Last updated at Posted at 2015-12-22

この記事は iOS Jailbreaking Advent Calendar 2015 の19日目の記事です。
2日分も書くことになるとは
18日目に続いて記事を書かせてもらう@ChikuwaJBです。
自己紹介等は18日目の記事に書いてあるので是非!

http://qiita.com/ChikuwaJB/items/f623e1b6c1d98dd21639

本題

http://i.imgur.com/cqZbjia.jpg

写真の赤丸の部分の作り方について書きたいと思います。

Binary側(mm,m)の編集

以下のコードを追加

Preference.mm


@protocol PreferencesTableCustomView
- (id)initWithSpecifier:(PSSpecifier *)specifier;
- (CGFloat)preferredHeightForWidth:(CGFloat)width;
@end

@interface FirstCustomCell : PSTableCell <PreferencesTableCustomView> {
    UILabel *label;
}
@end

@implementation FirstCustomCell
- (id)initWithSpecifier:(PSSpecifier *)specifier {
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell" specifier:specifier];
    if (self) {
        label = [[UILabel alloc] initWithFrame:[self frame]];
        [label setLineBreakMode:UILineBreakModeWordWrap];
        [label setNumberOfLines:0];
        [label setText:@"HelloWorld!"];
        [label setBackgroundColor:[UIColor clearColor]];
        [label setShadowColor:[UIColor whiteColor]];
        [label setShadowOffset:CGSizeMake(0,1)];
        [label setTextAlignment:UITextAlignmentCenter];
        [self addSubview:label];
        [label release];
    }
    return self;
}

- (CGFloat)preferredHeightForWidth:(CGFloat)width {
    return 60.f;
}
@end


plist側の編集

一番はじめのPSGroupCellに

キー:headerCellClassheaderCellClassにすればそのアイテムの下に指定したセルが挿入される。
値:FirstCustomCell←セルの名前

foo.plist

......

<dict>
 <key>cell</key>
 <string>PSGroupCell</string>
 <key>headerCellClass</key>
 <string>FirstCustomCell</string>
</dict>

.....

これだけです! 簡単!

動かしてみると。。。

http://i.imgur.com/pBaJIVg.png

こんな感じでちゃんと表示されていますね( ・ㅂ・)و ̑̑
ソースコードはGithub上で公開しています。

https://github.com/ChikuwaJB/AdventSample

今日もまた知ってるわそんなの!ヽ(`Д´)ノ
って言われそうな記事ですが参考になったら嬉しいです。。

初めてのiOS Jailbreaking Advent Calendar 2015でしたが、僕の担当は一応これが最後の記事のはず(?)です。

@r_plus氏から始まり、@wa_kinchan氏、@ichitaso氏、僕、@Adolfoi氏と有名な方々に囲まれてレベルの低い記事を書かせてもらえたiOS Jailbreaking Advent Calendar 2015のメンバーに感謝です!

来年も生きていたら(?)また書かせてもらえると嬉しいです( ・ㅂ・)و ̑̑

では良いJailbreak Lifeを!

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2