[UINavigationItem setBackBarButtonItem:] is ignored if created with custom view

Originator:sahil
Number:rdar://9685945 Date Originated:27-Jun-2011 05:26 PM
Status:Open Resolved:NO
Product:iPhone SDK Product Version:5.0b2
Classification:Bugs (Other) Reproducible:ALWAYS
 
27-Jun-2011 05:26 PM Sahil Desai:
Summary: 
UIBarButtonItem is ignored by -[UINavigationItem setBackBarButtonItem:] in case it was initialized with custom view. Default value with title of previous UINavigationItem is used instead.

Steps to Reproduce:
1. Create a viewController.
2. Set self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:[UIButton buttonWithType:UIButtonTypeRoundedRect]] autorelease];
3. Push a new view controller onto the navigation stack.  

Expected Results:
After pushing second view controller back bar button item must be rounded UIButton

Actual Results:
After pushing second view controller back bar button item is set to default with title of a previous view controller

Regression:
I noticed this for iOS 4.2/4.3 but searching on the Internet shows me that this issues exists since 2.0 SDK

Notes:
You can workaround it by setting leftBarButtonItem in second view controller (but have to set your own actions and targets, which is extremely cumbersome. You also lose the nice slide animation of the backButton coming from the right).

Duplicates

Number Status Originator Product Title
rdar://9728778 Duplicate/9685945 cedric.luthi iPhone SDK [UINavigationItem setBackBarButtonItem:] is ignored if created with custom view

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!