Как добавить динамическую / мульти кнопку в UINavigation Bar? - PullRequest
0 голосов
/ 05 декабря 2011

Как добавить динамическую / мульти кнопку в UINavigatation Bar?

Как на картинке ниже:

logmein tool bar

Ответы [ 2 ]

0 голосов
/ 05 декабря 2011

Вы можете использовать UIToolBar, который затем удерживает несколько объектов UIBarButtonItem.

- (void)viewDidLoad {
    [super viewDidLoad];




    // create a toolbar to have two buttons in the right

        UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 133, 44.01)];

        // create the array to hold the buttons, which then gets added to the toolbar
        NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];

        // create a standard "add" button
        UIBarButtonItem* bi = [[UIBarButtonItem alloc]
                               initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add)];
        bi.style = UIBarButtonItemStyleBordered;
        [buttons addObject:bi];
        [bi release];


        // create a standard "refresh" button
        bi = [[UIBarButtonItem alloc]
              initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh)];
        bi.style = UIBarButtonItemStyleBordered;
        [buttons addObject:bi];
        [bi release];

        // stick the buttons in the toolbar
        [tools setItems:buttons animated:NO];

        [buttons release];

        // and put the toolbar in the nav bar
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
        [tools release];

}

-(void)add{
    NSLog(@"Code to add the row in tableview");
}

-(void)refresh {
    NSLog(@"code to refresh the tableView");
}
0 голосов
/ 05 декабря 2011

Я не верю в iOS5, но в iOS4 вы можете сделать это только с помощью сублассинга (или даже создания собственного) навигации. бар, чтобы сделать его нестандартным.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...