Re: OK - I must be missing something simple here.
Re: OK - I must be missing something simple here.
- Subject: Re: OK - I must be missing something simple here.
- From: David Duncan <email@hidden>
- Date: Wed, 22 Jun 2016 14:01:14 -0700
> On Jun 22, 2016, at 1:36 PM, Alex Zavatone <email@hidden> wrote:
>
>
> On Jun 22, 2016, at 1:59 PM, David Duncan wrote:
>
>>
>>> On Jun 22, 2016, at 11:54 AM, Alex Zavatone <email@hidden> wrote:
>>>
>>>
>>> On Jun 22, 2016, at 10:51 AM, Alastair Houghton wrote:
>>>
>>>> On 22 Jun 2016, at 16:38, Alex Zavatone <email@hidden> wrote:
>>>>>>
>>>>>> Is the thing that you’re missing that IBOutlets are nothing special; they’re just a property (the syntax “IBOutlet” is there just to tell Xcode which things to show in the GUI editor). So you can set the property, just the same as you would any other property, from code. Does that help?
>>>>>
>>>>> I remember reading the docs that IBAction and IBOutlet are mainly conventions for the viewer.
>>>>>
>>>>> What I am saying is that I DO set the property to be the instance of the button.
>>>>>
>>>>> And nothing happens. By that, there is no visual change to the screen.
>>>>
>>>> You *are* updating the items property on the UIToolbar, right? Rather than just altering some random IBOutlet and expecting it to magically update the toolbar somehow?
>>>
>>> Alastair, you're getting confused.
>>>
>>> Why would there be a UIToolbar? This is just a plain old a UIButton.
>>
>> You started by mentioning that these buttons were being displayed as custom views on a UIBarButtonItem, hence the question.
>
> I'm sorry, David, I thought that I said that they worked under that condition.
>
> What is failing is when I have a UIButton instance (that I know is good, because i use that UIButton's instance to create the UIBarButtonItem, but I keep the UIButton instance around) and I have an IBOutlet to a UIButton on a storyboard scene's viewController.
>
> This IBOutlet to a UIButton class on the viewController has a 24 x 24 pixel dimensions in the viewController in the scene, if it matters.
>
> If I try to set the IBOutlet to one of the UIButton instance, nothing shows up.
Right. This is what I mentioned before – you are literally just setting a property. The old button would still be sitting there in the view hierarchy, just now you no longer have an explicit reference to it. You would need to insert the new button and remove the old one (as well as adapt any code that might be directly referencing the button that was in the view hierarchy).
IBOutlet is just a way to connect to instances created on the storyboard by Interface Builder.
>
> If I set the nav bar's right item to the UIBarButtonItem instance, that displays fine.
>
> If I have an IBOutlet that is a UIImageView and I set the image property of the UImageView to a UIImage instance, that also instantly displays fine.
>
>
> The only reason I know that the button should display something is because that's what I use to initialize the UIBarButtonItem.
>
>
>
> Basically, I have a signal strength meter and I'm just interested in swapping out the graphics on the fly as the signal value gets updated.
>
> When there is a nav bar on the screen, this graphic needs to be in a UIBarButtonItem and the nav bar handles all the placement of where it should go.
>
> But in screens where I have no nav bar, or if the signal strength is to be monitored by screens outside of the framework that this is all in, I needed to place the element differently. I tried to use the UIButton instances (not UIBarButtonItem) but the contents simply don't display and had to resort to UIImages.
>
> Thanks and sorry for the confusion.
>
>
>> Outlets aren’t magic here – all IBOutlet does is allow you to connect things in a storyboard. If you want to change the value of a property or instance variable backed by an IBOutlet you are free to do so – but you also need to implement all of the other things that might mean.
>>
>> That would mean for example that you need to insert the new view and remove the old view from its superview, or reset the custom view on a UIBarButtonItem, or reparent a view controller, or any other thing that might be relevant in the context.
>> --
>> David Duncan
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden