i addded UIBarButtonItem *addBarButton=[[UIBarButtonItem alloc] >initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertData)]; in the toolbar but + button is not getting proper alignment ?
            Asked
            
        
        
            Active
            
        
            Viewed 150 times
        
    1
            
            
        
        Shobhakar Tiwari
        
- 7,862
 - 4
 - 36
 - 71
 
- 
                    Please explain your problem in detail. – Irfan Mar 11 '14 at 05:35
 - 
                    actually i created a custom toolbar and added uibarbuttonitem (addbarbutton ) and self.editbarbutton item okk... edit button is appeared middle of the toolbar but addbarbutton is appeared in lower part of toolbar so here my code of uibarbuttonitem – Shobhakar Tiwari Mar 11 '14 at 05:38
 - 
                    UIBarButtonItem *addBarButton=[[UIBarButtonItem alloc] >initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertData)]; – Shobhakar Tiwari Mar 11 '14 at 05:38
 - 
                    So you are facing this problem in which iOS? – Irfan Mar 11 '14 at 05:44
 
1 Answers
0
            Add two UIBarButtonSystemItemFlexibleSpace items to your toolbar, to the left and right of your items
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[toolbar setItems:[NSArray arrayWithObjects:flexibleSpace, settingsButton,deleteButton,addButton, flexibleSpace, nil]];
[flexibleSpace release];
Adding these as you would any other toolbar items will distribute space evenly between the two of them
Hope this will help you.
        Irfan
        
- 4,301
 - 6
 - 29
 - 46
 
- 
                    i createad a custom toolbar and added two uibarbuttonitem ok and also set toolbar to the rightbarbutton of the navigationitem ? UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(180.0,20, 100, 30)]; NSArray *items=[NSArray arrayWithObjects:addBarButton,self.editButtonItem,nil]; [toolBar setItems:items]; UIBarButtonItem *barItem=[[UIBarButtonItem alloc] initWithCustomView:toolBar]; self.navigationItem.rightBarButtonItem=barItem; – Shobhakar Tiwari Mar 11 '14 at 05:52
 - 
                    yes you are facing issue because of there is no spacing between you toolbarbuttobs use above code it will resolve your issue hopefully. – Irfan Mar 11 '14 at 05:54
 - 
                    Check below links may it will help you: http://stackoverflow.com/questions/19233591/custom-uibarbuttonitem-alignment-off-with-ios7 http://stackoverflow.com/questions/18861201/uibarbuttonitem-with-custom-view-not-properly-aligned-on-ios-7-when-used-as-left – Irfan Mar 11 '14 at 06:06
 - 
                    okk ..thnx for suggesting this link .. let me chk it out first – Shobhakar Tiwari Mar 11 '14 at 06:29
 - 
                    You welcome if this info is helpful for you then accept my answer so it will be helpful others too. thanks – Irfan Mar 11 '14 at 06:44