Re: 'Back button' title for navigation item not sticking
Re: 'Back button' title for navigation item not sticking
- Subject: Re: 'Back button' title for navigation item not sticking
- From: Alex Zavatone <email@hidden>
- Date: Tue, 13 Oct 2015 14:01:26 -0400
On Oct 13, 2015, at 1:40 PM, Alex Hall wrote:
>
>> On Oct 13, 2015, at 12:54, David Duncan <email@hidden> wrote:
>>
>>
>>> On Oct 13, 2015, at 9:50 AM, Alex Zavatone <email@hidden> wrote:
>>>
>>>
>>> On Oct 13, 2015, at 9:34 AM, Alex Hall wrote:
>>>
>>>>
>>>>> On Oct 13, 2015, at 09:31, Alex Zavatone <email@hidden> wrote:
>>>>>
>>>>> FWIW, I have found no way to do this but in code.
>>>> Really? That's annoying, since Xcode offers what seems like such a simple solution right in the inspector. I wonder if it's an Xcode bug, or if I'm misunderstanding what that text field in the inspector does? If it's a bug, I'll file it, though I'm sure many others already have.
>>>
>>> Yeah, I noticed long ago, (Xcode 4.3?) that the text I had entered in the storyboards for the name of the back button no longer was obeyed in the screens that I created. Maybe it was iOS 6, but I forget.
>>>
>>> Today, I create the a UIBarButtonItem with a title and set it to the self.navigationIdem.leftBarButtonItem using a GCD dispatch_after.
>>>
>>> I tried doing it directly, but the UI would wait for 20 seconds before it took
>>
>> Under what circumstance? I’ve never seen this reported by anyone, so this sounds like its either an error in your application or an edge case that I’m not aware of.
>
> To clarify, do you mean the UI taking a long time to update, or the back button title field in the Attributes Inspector not affecting the app? I'm seeing the latter problem, and haven't yet tried the in-code solution.
Well, there are two issues. When I tried this within the viewDidLoad…
self.navigationItem.leftBarButtonItem = leftButton;
The UI took 20 seconds before it updated and it was non responsive the whole time (iOS 8).
When setting a custom name for the title of the back button in the storyboard, I haven't seen that work since Xcode 4.2 and iOS 5.
>>
>> If you need to do this to update your bar button items, please submit a bug report with a sample demonstrating the issue. This code should not be necessary ever.
>>
>>> , so I used a GDC dispatch and it gets the job done.
>>>
>>> Here is is in a little method for you. You can modify it to pass in the selector so that it's more general purpose.
>>>
>>> Notice the commented out line below the closing paren. Try commenting out the dispatch and using that instead and watch as your UI takes 20 seconds to update.
>>>
>>> - (void) createBackbuttonWithTitle (NSString *)buttonTitle {
>>> UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(buttonTitle, nil)
>>> style:UIBarButtonItemStyleDone target:self action:@selector(dismiss:)];
>>> dispatch_after(dispatch_time(DISPATCH_TIME_NOW, .5 * NSEC_PER_MSEC),
>>> dispatch_get_main_queue(),
>>> ^{
>>> self.navigationItem.leftBarButtonItem = leftButton;
>>> });
>>>
>>> // self.navigationItem.leftBarButtonItem = leftButton;
>>> }
>>>
>>>
>>> Hope this helps ya out.
>>>
>>> Cheers,
>>> Alex Zavatone
>>>
>>>
>>>>>
>>>>> Sent from my iPhone
>>>>>
>>>>>> On Oct 12, 2015, at 9:11 PM, Alex Hall <email@hidden> wrote:
>>>>>>
>>>>>> Hi all,
>>>>>> I have a navigation item inside a view, which is a couple levels inside a navigation controller's stack. I can change the title of the navigation item through the "title" attribute (in IB) with no trouble. However, when I entered some text for the "back button" title, Xcode shows that text in the Attributes Inspector, but it isn't used in my app. Instead of "cancel" as I wrote, I get the standard "[previous view name] back" text instead. I'm assuming I've missed a step, but I'm not sure what. Thanks for any suggestions; I know this must be an easy fix, but the only things I can find online are all doing this with code.
>>>>>>
>>>>>> --
>>>>>> Have a great day,
>>>>>> Alex Hall
>>>>>> email@hidden
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Do not post admin requests to the list. They will be ignored.
>>>>>> Xcode-users mailing list (email@hidden)
>>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>>
>>>>>> This email sent to email@hidden
>>>>
>>>>
>>>> --
>>>> Have a great day,
>>>> Alex Hall
>>>> email@hidden
>>>>
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Xcode-users mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>> --
>> David Duncan
>>
>
>
> --
> Have a great day,
> Alex Hall
> email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden