Лучше всего написать подкласс UIViewController (например, назвать его CustomUIViewController
).
в методе viewDidLoad этого класса вы можете добавить соответствующее представление, например:
- (void)viewDidLoad {
UIView *bar = [[[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,28)] autorelease];
UIButton *buttonOne = [UIButton buttonWithType:UIButtonTypeRoundedRect];
// etc...
[bar addSubview:buttonOne];
UIButton *buttonTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect];
// etc...
[bar addSubview:buttonTwo];
[self.view insertSubview:bar atIndex:0];
}
Это должно сработать (если вы не забыли звонить [super viewDidLoad]
во всех ваших классах.
Теперь вам просто нужно убедиться, что вы подклассифицируете CustomUIViewController вместо UIViewController в ваших контроллерах представления.
Редактировать
Чтобы заставить работать панель навигации, сделайте следующее:
UIBarButtonItem *cancel = [[[UIBarButtonItem alloc] initWithTitle:@"Cancelsdkjfnsdjfhksdjfhks" style:UIBarButtonItemStylePlain target:self action:@selector(cancel:)] autorelease];
[self.navigationItem setLeftBarButtonItem:cancel];
UIBarButtonItem *send = [[[UIBarButtonItem alloc] initWithTitle:@"Senddsfsdfsdfsdfsdfsdf" style:UIBarButtonItemStylePlain target:self action:@selector(send:)] autorelease];
[self.navigationItem setRightBarButtonItem:send];
self.navigationItem.titleView = [[[UIView alloc] init] autorelease];