Presenting modal view occasionally hides the navigation bar

后端 未结 4 1712
夕颜
夕颜 2021-01-01 17:48

I\'ve come across this twice now.

Sometimes using the following line of code:

[self.navigationController presentModalViewController:aViewControll         


        
4条回答
  •  鱼传尺愫
    2021-01-01 18:08

    @HeatMiser shows a great way to get around the "bug" surrounding the inability to display items on the nav bar. I'm not sure, however, if this is strictly a bug in Presentation, since modal operations ought to trump the underlying view's interface theme. Having the modal operation's theme mimic the underlying UI theme is fine, but wrapping the true modal view with a navigation view feels wrong to me (extra view object just to get a little more behavior).

    Instead, the following worked for me and gives the same behavior as "New Message" does in the Mail program (on the iPhone).

    In IB, place a UIToolBar at the top of the modal screen (mimicking the navigation bar) with "Cancel" and "Save" UIBarButtonItem's and a Flexible Space Bar Button Item in between to get the buttons to align left and right. Then, add a UILabel centered over the UIToolBar (The Font Helvetica, Bold, Size 18 appears to match the Navigation Bar Title). Connect the buttons to IBAction's on the modal's UIViewController, and you're done.

提交回复
热议问题