Search code examples
iphonefacebookuinavigationcontrollerxcode4.2

how iphone facebook app make the navigation bar fixed


I'm new in iPhone development and want to ask about the navigation controller. How can I make the navigation controller fixed over the whole application, like the facebook navigation bar. It always shows the notification, friends and messages in the navigation bar.

I'm trying to put custom view in the titleView but it disappears every time the navigation push new view?


Solution

  • this is what worked for me:

    toolBar = [[UIView alloc]initWithFrame:CGRectMake(105, 20, 105, 44)];
    notificationsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    messagesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [notificationsBtn setImage:[UIImage imageNamed:@"notifications-icon.png"] forState:UIControlStateNormal];
    [notificationsBtn setFrame:CGRectMake(35, 0, 35 , 44)];
    [notificationsBtn addTarget:self action:@selector(showNotifications:) forControlEvents:UIControlEventTouchUpInside];
    
    [messagesBtn setImage:[UIImage imageNamed:@"messages-icon.png"] forState:UIControlStateNormal];
    [messagesBtn setFrame:CGRectMake(70, 0, 35 , 44)];
    [messagesBtn addTarget:self action:@selector(showMessages:) forControlEvents:UIControlEventTouchUpInside];
    
    [toolBar addSubview:notificationsBtn];
    [toolBar addSubview:messagesBtn];
    
    [_window.rootViewController.view addSubview:toolBar];