views:

54

answers:

1

I change the UIBarButtonItem title at run time but it does not work

if(self.toolbarItems!=nil)
    {
        NSArray *toolbaritem=self.toolbarItems;
        UIBarButtonItem* tmpeditButton =[toolbaritem objectAtIndex:0];
        tmpeditButton.title=@"Done";
        NSLog(@"log %@",tmpeditButton.title);
    }

Log is always displays the value of NULL. Why and how to fix that?

+1  A: 

Use this

UIBarButtonItem *barButton = [[UIBarButtonItem  alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:nil];
Gyani