I want to add back button on NavBar in iOS, but I can't find back array image on systemItem. Is there any property of default back arrow image.
I tried SMF.UI.iOS.BarButtonType.cancel but it has a title says "Vazgeç" instad of back arrow image.
You must assign onSelected event of back item.
Can you try this;
var leftItem = new SMF.UI.iOS.BarButtonItem({
systemItem : SMF.UI.iOS.BarButtonType.cancel,
onSelected : Pages.back()
});
this.navigationItem.leftBarButtonItems = [leftItem];
You should use Navigation Controller for that. Then the back button will appear automatically.
If you want to display only image, without text, put this code in the view controller that you came from.
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:#"" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
Related
I feel daft asking this question, but I haven't been able to get this to work. I have a NavController->TableViewController->WebViewController. I'm trying to change the title of the backButton on the WVC from the default "Back" to "Reference".
This should be a simple matter of setting the text property of the Back button either in Storyboard (which isn't working) or in code of my WebViewController's viewDidLoad method:
self.navigationItem.backBarButtonItem.title = #"Reference";
Is this just a bug or am I missing something?
Put this in your tableviewController
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:#"Reference" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
Screen shot
From document
If you want to specify a custom image or title for the back button, you can assign a custom bar button item (with your custom title or image) to this property instead.
You should set it in your TableViewController, not in your WebViewContorller
Solved: I had added a grey activity indicator in a small view in the nav bar of the WVC. After I removed it, the code worked fine. Thanks #Leo, #Jacky, #Jaleel!
this work for me
self.navigationController.navigationBar.topItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Reference" style:UIBarButtonItemStylePlain target:nil action:nil];
I have the back buttons translated to german ("Zurück"). However, it seems that when there isn't enough space (because of the length of the title) it is shown as "back". And if there is only very little space, no title is shown at all, only the chevron "<".
Is there a way for it to not show the back buttons with the "back" title, but only as "<" if there isn't enough space for "Zurück"?
You can override loadView and put this code in your view controller:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"" style:UIBarButtonItemStylePlain target:nil action:nil];
You could calculate the text length before that in order to decide if you want to show the back button with title or without it.
Edit
It's better to do this in a UIViewController superclass and have all your view controllers extend that class.
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
forBarMetrics:UIBarMetricsDefault];
Then you can remove the back button item title.
If you use Storyboard, you can set navigation attributes inspector Back Button with space.
You can follow this link
So I am just using a normal View Controller. I dragged a Navigation bar to the top and added a UIBarButtonItem with the 'pause' identifier.
I want to be able to change that identifier to the 'play' one.
Is this possible? I can't find any information on it.
I tried creating a new one, but not really sure where to go from there.
UIBarButtonItem *flipButton = [[UIBarButtonItem alloc]
initWithTitle:#"Flip"
style:UIBarButtonItemStyleBordered
target:self
action:#selector(flipView)];
Any help would be great.
You're looking for the UIBarButtonSystemItemPlay. Just set it up, assign your selector and target, and choose which barButtonItem you want.
UIBarButtonItem *playButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:#selector(playButtonPressed:)];
self.navigationItem.rightBarButtonItem = playButton;//Or leftBarButtonItem if you want it to be on the left
I've a WebviewViewController and a navigation bar with the Back Bar Button. Now I want two buttons on the right of the bar, a goBack and a goForward. I've searching for a while and none of the answers works properly.
There's a way to add them in the storyboard or only programmatically? If so, how do I do it?
I did it in the past, it's easy:
myBackBarButton = [[UIBarButtonItem alloc] initWithImage:barButtonImage
style:UIBarButtonItemStylePlain
target:myWebView
action:#selector(goBack)];
myForwardButtom = [[UIBarButtonItem alloc] initWithImage:anotherBarButtonImage
style:UIBarButtonItemStylePlain
target:myWebView
action:#selector(goForward)];
Where myWebView is your UIWebView (In case it's your class, use self)
If your buttons are already created, then just add the target and the action to them:
myBackButton.target = myWebView;
myBackButton.action = #selector(goBack);
What you are doing is adding the action goForward: and goBack: of the target that is your webview, to those buttons.
I'm trying to have a button on the right side of my navigation controller - after this works I'd like the button to be as near to invisible as possible while still working. Maybe setting to high transparency or changing the colour to the navigation bar colour (whatever is cheaper for memory).
First though I can't seem to get a visible or working button on the right side of my navigation bar:
self.navigationController.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:#"coin" style:UIBarButtonItemStyleDone
target:self action:#selector(changeToInAppScene:)];
You have to assign to self.navigationItem.rightBarButtonItem (the navigation item of the current view controller), not self.navigationController.navigationItem.rightBarButtonItem .
- (void)viewWillAppear:(BOOL)animated
{
UIBarButtonItem *rightBar = [[UIBarButtonItem alloc]initWithTitle:#"Coin" style:UIBarButtonItemStylePlain target:self action:#selector(changeToInAppScene:)];
self.navigationItem.rightBarButtonItem = rightBar;
}