Как программно добавить UINavigationBar и кнопку возврата на него

Я новичок, пытающийся сделать приложение, похожее на приложение Notes для iPhone, используяUITextView, Я получаюtextView и линии и все работает нормально.

Моя проблема в том, что я хочу добавитьUINavigationBar и кнопка назад на нем. И я хочу добавитьUIToolBar внизу и 2 toolBarItems на нем, как это сделать программно. Любая помощь будет большим толчком для меня ..

ниже приведен фрагмент кода.

NoteView.h

@interface NoteView : UITextView 
{

}

NoteView.m

- (id)initWithFrame:(CGRect)frame {

  self = [super initWithFrame:frame];

  if (self) {
      self.backgroundColor = [UIColor colorWithRed:0.6f green:0.6f blue:1.0f alpha:1.0f];
      self.font = [UIFont fontWithName:@"MarkerFelt-Thin" size:20];
      self.contentMode = UIViewContentModeRedraw;
  }
  return self;
}

- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext(); 

    CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.2f].CGColor);
    CGContextSetLineWidth(context, 1.0f);

    CGContextBeginPath(context);

    NSUInteger numberOfLines = (self.contentSize.height + self.bounds.size.height) /   self.font.leading;

    CGFloat baselineOffset = 6.0f;
    for (int x = 0; x < numberOfLines; x++) {
        CGContextMoveToPoint(context, self.bounds.origin.x, self.font.leading*x + 0.5f + baselineOffset);
        CGContextAddLineToPoint(context, self.bounds.size.width, self.font.leading*x + 0.5f + baselineOffset);
    }

    CGContextClosePath(context);
    CGContextStrokePath(context);
}

AddNotesViewController.h

@interface AddNotesViewController : UIViewController 
{
    NoteView *note;
}

@property (nonatomic, retain) NoteView *note;

@end

AddNotesViewController.m

- (void)loadView 
{
    [super loadView];
    self.note = [[[NoteView alloc] initWithFrame:self.view.bounds] autorelease];
    [self.view addSubview:note];
    note.delegate = self;
    note.text=@"";
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [note setNeedsDisplay];
}

- (void)textViewDidBeginEditing:(UITextView *)textView 
{
    CGRect frame = self.view.bounds;
    frame.size.height -= KEYBOARD_HEIGHT;
    note.frame = frame;
}

-  (void)textViewDidEndEditing:(UITextView *)textView 
{
    note.frame = self.view.bounds;
}

- (BOOL)textView:(UITextView *)textView 
shouldChangeTextInRange:(NSRange)range 
        replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    return YES;
}

Подскажите пожалуйста как и где добавить навигационную панель, кнопку назад и панель инструментов, 2 панели инструментов на ней. Заранее спасибо ...

Ответы на вопрос(2)

Ваш ответ на вопрос