views:

360

answers:

3

I have added the one button on right side of the navigation bar with this code, but i want to add the three buttton like this but i am adding with this code, I think button is overlap on one place , i am able to see only one button on right side of navigation bar.

         UIButton* modalViewButton1 = [UIButton buttonWithType:UIButtonTypeInfoLight];
           [modalViewButton1 addTarget:self action:@selector(modalViewAction1:)          forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *modalBarButtonItem1 = [[UIBarButtonItem alloc] 
          initWithCustomView:modalViewButton1];
         self.navigationItem.rightBarButtonItem = modalBarButtonItem1;
     [modalBarButtonItem1 release];
A: 

If you are assigning 3 buttons to rightBarButtonItem then of course you are overwriting the same right bar button item ... there is only one rightBarButtonItem

self.navigationItem.rightBarButtonItem
stefanB
+2  A: 

It sounds like what you want isn't offered in the API by default, so what you'll need to do is create your own UIView subclass that displays 3 buttons. Then set your navigationItem to have its rightButtonItem be a new UIBarButtonItem with a custom view like so:

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:YOUR_VIEW];
dbachrach
can u give me some sample code for the belove.when i click on any right side button of navigation bar ,i want to go on another view.
uttam
A: 

The way I do it here on the image below for instance is to use a UISegmentedControl as a custom view of the UIBarButtonItem : Then you inherit the multiple boutons that are part of the segmented controls. On this image I use the same for left and right buttons of the navigation bar.

alt text

yonel