Originally I used to create UIButton assignment to Self.navigationItem.leftBarButtonItem the way to set the return button, with a feel quite normal, the results of the "Frog cow" in the article "Java to ios-the first project summary (2)", A major problem has been found: The gesture return function is gone because the ability to customize the return button with the Leftbarbuttonitem setting will cause the gesture return to fail.
If I do not customize the return button, and because I am using rdvtabbarcontroller, I need to manually set the Hide Tabbar property in the return method, so I need to intercept the triggering method of the return gesture, remembering that the story is big.
Groping for half a day, found a simple custom return button and retain the ability to return gestures, the way to optimize the hide Tabbar can not be intercepted. Define a Isshowtabbar in Baseviewcontroller, default to No, set isshowtabbar=yes in the Init or Initwithnibname method of a first-level page, Other Viewcontroller do not move, Baseviewcontroller rewrite the following method:
-(void) Viewwillappear: (BOOL) animated{[Super viewwillappear:animated]; if (Self.rdv_tabBarController.isTabBarHidden = = Isshowtabbar) {[Self.rdv_tabbarcontroller settabbarhidden:!isshowt Abbar]; }}
Customize the return button code without text as follows: (code from custom iOS7 navigation bar background, title and Back button text color)
Custom return button UIImage *backbuttonimage = [[UIImage imagenamed:@ "Fanhui.png"] resizableimagewithcapinsets: Uiedgeinsetsmake (0, 30, 0, 0)]; [[Uibarbuttonitem appearance] Setbackbuttonbackgroundimage:backbuttonimage forstate:uicontrolstatenormal Barmetrics:uibarmetricsdefault]; The text position setting for the return button is not displayed on the screen [[Uibarbuttonitem appearance] Setbackbuttontitlepositionadjustment:uioffsetmake ( Nsintegermin, Nsintegermin) Forbarmetrics:uibarmetricsdefault];
The display results are as follows:
ios7+ Custom Back button