私は、人がABUnknownPersonViewControllerが選択されたときに、UITableView内の人のリストを表示するアプリケーションのAddressBookを作成しました。このABUnknownPersonViewControllerから、ユーザーは(組み込み機能を使用して)その人物を「新しい連絡先」または「既存の連絡先」に追加することができます。ABPeoplePickerNavigationControllerのNavigationBarでのタイトルのカスタマイズ
ここに私の問題があります。私は、アプリケーション全体でNavigationBarタイトル用のカスタムUILabelを使用しています。そして、私は "新しい連絡先の追加"/"既存の連絡先への追加"によってプッシュされるビューに対してこれを行うことができる必要があります。
私はABNewPersonViewControllerのカテゴリを作成して "Add New Contact"のためにこれを解決しましたが、 "Add to Existing Contact"では同じアプローチが機能しません。私はこれがプッシュされたABPersonPickerNavigationControllerであるという事実のためかもしれないと思います。
@implementation ABPeoplePickerNavigationController (customTitle)
-(void)viewDidLoad {
[super viewDidLoad];
self.navigationBar.tintColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1];
}
NavigationBarのtintColorの色の変更はうまくいきますが、タイトルにアクセスするための適切な方法はありません。 ABUnknownPersonViewControllerからプッシュされたABPeoplePickerNavigationControllerのタイトルを変更することができる実際の例を含むヘルプは非常に賢明になります。私は、この目的のためにカスタムラベルを使用し
@implementation ABNewPersonViewController (customTitle)
-(void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1];
}
-(void)setTitle:(NSString *)theTitle {
CGRect frame = CGRectMake(0, 0, 45, 45);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont systemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithWhite:255.0 alpha:1];
label.shadowOffset = CGSizeMake(1, 1);
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor colorWithRed:23/255.0 green:23/255.0 blue:23/255.0 alpha:1];
self.navigationItem.titleView = label;
label.text = theTitle;
[label sizeToFit];
}
@end
ええ私のテキストで説明しようとしたように私のカスタムUILabelも作成します。「アプリケーション全体でNavigationBarタイトルにカスタムUILabelを使用しています。 私の問題は、実際にUILabelをNavigationBarのタイトルに設定するカテゴリからタイトルにアクセスできなくなることです。 – oehman
私は、うまくいけば物事をより明確にするために私の記事を編集しました。 :) – oehman