0

Possible Duplicate:
iPhone : making UIBarButtonItem that is arrow shaped
Creating a left-arrow button (like UINavigationBar's "back" style) on a UIToolbar

I have a modal viewController with a navigation bar. And, I want to create a back button on a modal viewcontroller. Now, I am aware of the following method :-

[self.delegate dismissModalViewControllerAnimated:YES];

and for now, I'm calling it from a leftBarButtonItem.

But, my problem is exactly that. It's a leftBarButtonItem that looks like a regular leftBarButtonItem. While, what I want is a button that looks like a backBarButtonItem with the pointy/arrow-like left side.

EDIT: I have reasons for specifically wanting to use a modal viewController and a back button. Kindly refrain from telling me to not use either one of the two. Thanks.

Community
  • 1
  • 1
Sam J.
  • 685
  • 1
  • 8
  • 22
  • You are duplicating this question: http://stackoverflow.com/questions/2330157/iphone-making-uibarbuttonitem-that-is-arrow-shaped?lq=1 and this one: http://stackoverflow.com/questions/227078/creating-a-left-arrow-button-like-uinavigationbars-back-style-on-a-uitoolba – Justin Paulson Aug 15 '12 at 17:01

1 Answers1

4

You would have to fake it with a custom image but in reality that's breaking the default behavior since the arrow implies navigation but a modal view controller is usually within the context of the current view controller and not moving forward or backwards. Your current solution may be the best.

rooster117
  • 5,502
  • 1
  • 21
  • 19
  • 1
    You should really be using a blue "done" button, not a navigation button. – Dustin Aug 15 '12 at 16:24
  • Thanks guys, I have reasons for wanting to use the back button, instead of the "done" button or leftBarButtonItem. @rooster117 Any pointers for what I should be looking at, to fake it with a custom image? – Sam J. Aug 15 '12 at 16:33
  • as suggested by @rooster117, push your view controller onto the navigation stack, don't use it as a modal vc. Then you'll get back navigation as expected – CSmith Aug 15 '12 at 16:46
  • @CSmith I have reasons for wanting to use a modal viewController just like I have reasons for wanting to use the back button. – Sam J. Aug 15 '12 at 16:51
  • Modal views are dismissed (i.e. closed), not navigated back from. You're getting the right feedback here, read the Apple HIG document for more information. – CSmith Aug 15 '12 at 17:11
  • @CSmith Yes, I am aware of that, thanks for nothing! – Sam J. Aug 15 '12 at 17:47
  • First you're going to have to get the back button image and just look at how to add a custom button with image to the bar. I would recommend using this project to get native artwork for this use or any other time you want native looking art: https://github.com/0xced/UIKit-Artwork-Extractor/ – rooster117 Aug 15 '12 at 17:52