Wednesday, January 15, 2014

Newcomers help: UINavigationBar of backbarButtonItem problem.

These days a lot of problems encountered in the operation of the custom backbarButtonItem,

Just started trying to replace the system backbarButtonItem pictures directly modify invalid due only to create a UIBarButtonItem, then
Assigned to self.navigationItem.backbarButtonItem.

UIBarButtonItem * back = [[UIBarButtonItem alloc] init];
back.style = UIBarButtonItemStyleBordered;
back.image = [UIImage imageNamed: @ "back"];
back.title = @ "xxx";
self.navigationItem.backBarButtonItem = back;
[Back release];

Then found, image content change is Button image, not the background image.
So instead: [back setBackgroundImage: [UIImage imageNamed: @ "back"] forState: UIControlStateNormal barMetrics: UIBarMetricsDefault]; this does not work, do not know what changed, anyway, style or system style buttons.

Then changed to: [back setBackButtonBackgroundImage: [UIImage imageNamed: @ "back"] forState: UIControlStateNormal barMetrics: UIBarMetricsDefault];
Has the effect, however, Nima, and why the text on the button one more shaded background it? Remove the text look ......
Damn, the text still there, but from the "xxx" to restore the system became "Back". After tried numerous ways, not always able to get rid of the text.
Great God wanted to ask you, can remove the text and the background of his shadow?

And later tried to use a custom Button, set the view to backbarButtonItem property and found it does not directly show.
However, if the button as navigationItem the left button or right button can all be displayed:
self.navigationItem.leftBarButtonItem = back; this is possible, button effects is what I wanted, but he did not backbarButtonItem function ah.

I do not know who can help me Great God look at this issue?



Reply:
Depth is the easiest way to customize the system to hide the navigation bar, fully their own.
Reply:
Project cycle does not allow ah ......

Reply:
Just a navigation bar only, a UIView, plus two buttons, label above, is not complicated
Reply:
Reference: http://stackoverflow.com/questions/3093468/customize-uibarbuttonitem-with-background-images
Reply:
Method 1: Direct quote the text on the picture
Method 2: Use navigation of leftbar, then push pop controller on the line, how it will be no back function
Reply:
references, 5th Floor reply:
Method 1: Direct quote the text on the picture
Method 2: Use navigation of leftbar, then push pop controller on the line, how it will be no back function


Method 2 is possible, but this is the case, is push each interface, custom leftbar should not say,
The key is, leftbar with backbar little difference, that is, at the time of return, backbar there is a gradual shift + animation animation,
leftbar only gradual animation.

Now it seems that I can only use two of the methods.

Reply:
UIButton * button = [UIButton buttonWithType: UIButtonTypeCustom];
[Button setFrame: CGRectMake (0, 0, 60, 44)];
[Button setBackgroundImage: [UIImage imageNamed: @ "bt_back.png"] forState: UIControlStateNormal];
[Button setBackgroundImage: [UIImage imageNamed: @ "bt_back_over.png"] forState: UIControlStateHighlighted];


self.leftBtnBackItem = [[[UIBarButtonItem alloc] initWithCustomView: button] autorelease];
Reply:
With leftBtnBackItem, and then add a button to the event, in the event where the return





Reply:
Landlord, I also have the same problem and you both want to keep the transition animation, want to modify button image, but it is not solved, do not know what you did to solve.

No comments:

Post a Comment