Choose correct UIButton on dynamiclly created buttons without tags - iphone

I am loading up a plist file and creating buttons based on this file. These buttons can change at any point during the application running (which will trigger an update of all the buttons etc).
One set of buttons represents a list of categories. So I may have a house button, car button, etc. No matter what button is pressed it will call my categoryButtonPressed:(id) sender function. I need to know what button called it and load a second set of data based on the button (category) that was pressed.
So if I press the house button, the function needs to load the house data, but how can I determine what button was pressed in that function. If I use tags I have to know that the house button is tag 1, car is tag 2 and so forth. BUT I don't know if there will even be a house button until I read that file. Do I need to code the tag into the plist file as well?
OR is there a way to loop through my Array of UIButtons and determine this? Any advice?
And last, if I create my own extended version of UIButton that added a "name" variable, would I would still be out of luck because the action would pass the UIButton base and comparing my extended class to the base would always fail correct?
Thanks for any and all help!

And last, if I create my own extended
version of UIButton that added a
"name" variable, would I would still
be out of luck because the action
would pass the UIButton base and
comparing my extended class to the
base would always fail correct?
The action is passed by whatever control, of whatever class, the action was registered with. Creating your own custom button with additional properties seems like the way to go.
You could also set the tag of the button as the index in your button array, or the index in the plist that the button corresponds to.

Related

Changing the default displayAction and playAction labels in tvOS in Top Shelf

On tvOS if you look at the native Music or Arcade app's top shelf area their "play" action has the label of "Watch Playlist" and "Get" respectively. However I don't see a way to edit these values in my own app as the TVTopShelfAction is an NSObject with a single value: URL so I would assume this is just for directing the user based on where the button goes and there's no labelling props available for the container class as well (TVTopShelfCarouselItem).
The docs say: https://developer.apple.com/documentation/tvservices/tvtopshelfaction
"When configuring items for a carousel interface, you can specify a custom title and image for the buttons in that interface. If you do not specify a custom title and image, the system chooses default values based on whether you assigned the action object to the playAction or displayAction property of your item."
But it's unclear if that is referring to the TVTopShelfCarouselItem which the action becomes a part of and what value I should be changing to customize it. So is this something that's hidden in the TVTopShelfCarouselItem's namedAttributes prop? And if so...which one?
I've had this same problem. I've asked Apple about it and they responded that the documentation is wrong. There is currently no way to change the button titles.
There is also no way, that I'm aware of, to display the item's title without the user having to tap for details.
Hopefully in the future this ability is added.
I'd love to know if you find a way.

Assign Radio Group to Radio Buttons

I have several radio buttons
I need to assign a radio group to it so that only one radio button is selectable at a time.There is no radio group option.I have tried
Assigning a single action outlet to all buttons
Putting all buttons in a custom view
None of this works.
In the old days, NSMatrix was the class that provided the radio group behavior. If you look up the docs for that class, you'll find the following note:
Use of NSMatrix is discouraged in apps that run in macOS 10.8 and later. If you need to create a radio button group in an app that runs in macOS 10.8 and later, create instances of NSButton that each specify a button type of NSRadioButton and specify the same action and the same superview for each button in the group.
So there are three things that all need to be true at the same time for this to work:
Your buttons all have to share the same superview.
Your buttons all have to have the same action.
Your buttons need to have their button type set to NSRadioButton.
I tried this out just now. I created a button in a view in my storyboard, set it's button type to "Radio" in the Attributes inspector, and assigned an action. Then I duplicated that button several times, and ran the app. The radio behavior worked automatically.
If it's not working for you, I'd start by doing what I did above. Just create a single radio button and set it up with an action. Then duplicate it a few times and test. If that works (it should), then either see if you can use that technique to get what you want, or look at what's different between what you want and what works.

Can I add 2 different button classes' in a trigger under the main tag and get proper data in my GA?

In a pricing page, there is a "Buy" button when user clicks on the button, it takes to a page where the user chooses payment type and again there is a button with another class, I want to track both of them. Is it possible to set up 2 button classes(in one trigger) under the button click tag and get proper data in GA?
You can achieve this, but not in this way, as visible on your screenshot. These conditions have AND relation. So your current trigger requires a click on an element with a class containing payment-button price-btn AND btn-pay at the same time.
So you need to create two separate triggers for the two class variants, and attach both of them to the same tag as firing triggers, as those will have OR condition among themselves.
Please note, that payment-button price-btn will look for this string. So if there's any chance, that the classes don't appear in this exact order, you might want to go for just one of them, or separate these two classes in two rows of one trigger, payment-button and price-btn.

UITextField Keep the placeholder text on while focused

I want to keep the place holder text shown while it is focused (that is, while it is the first responder). It should stay that way only until something is typed and the field no longer blank.
Address Book app's Search bar behaves like this, as do the new contact entry fields.
Is there any way to do that?
I don't think this comes "built in" for you to activate it, but you can build it rather easily on your own: Create a UILabel you want to display and when the focus is set onto the TextField place the UILabel at the right spot (slightly after the cursor).
As soon as the user enters a character you hide the UILabel. You can see when the user starts the edit and starts to type by adding your class as delegate to the UISearchBar (see callbacks "searchBar:textDidChange:" and "searchBarTextDidBeginEditing:"): http://bit.ly/eQlvRz

UITableView form

I am having very annoying issue. I have one form page with 5 custom cells. Each of them has one text field. On the bottom I have one button. In an onclick button function I am gathering values from each of the 5 described text fields.
My problem is that if my keyboard is up, I will get the values of not all but just visible text fields, the ones I don't see are null.
How to override this?
Thx,
Mladen
Separate data you have from your interface, that is store your textfield values in some other place right after you finish input. And access your data there.
UI elements are not intended to store data, but just to display it and allow input - as you can see in your case if you do not see a particular element you cannot be sure that it actually exists.
This might solve your problem..
1. Register your viewcontroller for KeboardNotifications
2.When keyboard will appear resize the view so that all fields will be visible.
3. When keboard will disappear just resize it back and continue..