How to control display in UIPickerView using selected state of button - iphone

hi i have used UIButton and also UIpickerview,when i select value(select team) ,the value is changed(india).but
when i hold the button(india) ,the value is changed to initial value(select team).if i release the button from pressing ,the value is changed(india).but i want to do when i hold , the button must show (india) ...i want to use selected state configuration...anyhelp?

What is value here? UIPicker's value? or it's some other control in your view?
Check out Highlighted state for UIButton in Interface Builder... hope this helps!

Related

UIButton's Selected State not working in iOS7

I am using Xcode 5's storyboarding to create an application, iOS SDK 7.0.
I dragged a button to the View. I want my button to display "A" by Default. Below are the button properties:
Type: System, State Config: Default, Title: Plain
I want my button to display "B" in selected state. So, the button properties that changed:
State Config: Selected
In the Button's Attribute inspector, under the Control, there is a property called Selected.
If I check Selected, instead of displaying "B", it just highlights like a marker over A, i.e, no character is seen.
I ran it in XCODE. WHen the button is not selected "A" is displayed as expected but when I select the button, instead of displaying B, the text portion of the button is highlighted with light blue color. Also, I never selected the Highlighted Content under the Control.
How can this be resolved, so that I can display the state correctly?
For anyone who set the button title by code, I found on iOS 7.1, you need to explicitly set title for various button states, while on iOS 7.0, setting title for UIControlStateNormal will also do for other button states.
// works on 7.0
[self.ibActionButton setTitle:NSLocalizedString(#"Register", nil) forState:UIControlStateNormal];
// works on 7.1
[self.ibActionButton setTitle:NSLocalizedString(#"Register", nil) forState:UIControlStateNormal|UIControlStateDisabled];
You need to set the title of the button to 'B' while you have State Config set to Selected in your storyboard. Then you need to connect an action to the button's Touch Up Inside event. Inside of that action, toggle the button's selected property.
When you check 'Selected' under the Attributes Inspector, you are just setting the button's initial selected state to YES. XCode also shows you what the button would look like in that state.
I found that this is a bug in XCODE 5, that is, when we check the selected property under Control for the button, it doesn't show the selected state on the Button. It works in the simulator we run the application. We would need to do a target-action for the button and toggle the selected state as below
- (IBAction)flipButton:(UIButton *)sender {
sender.selected=!sender.isSelected;
}

Display a message when cursor over on UILabel

How can I display some text message when a label is tapped?
I have a label (Address).Now and when I tap over on it, I need to display the corresponding address in a small popup.
How can I do it?
I found out from your comment that you actually want to have a pop up on tap event.
All you need to do is
Have a button on the UILabel (on which you want to show pop up).
Make button of cutom type (It will make the button disappeared).
After that write a method to show pop up, and connect it to that custom button.
For creating a pop up, you can use UIView of desired size and position & make it appear/disappear on custom button tap event (touch up inside).
Hope this helps.

UIButton to forward events & retrieve values according to UIButton

I have a for loop that displays 7 UIButton all with a method pointing to the same view ( for loop , thats why) .
What i want is that when for
e.g ,i click on button1 , the next view will display values that belongs to button1 .
and when i click on button2 , the next view (same view again) will display values that belongs to button2.
Any idea on how to work on that?
I have classes and appDelegate to store this values in it
Edit:
my UIButton is programmatically created, i cannot link IBAction to it. I think a few have mistaken about my question.
For that, When you are looping for button, at that time, give tag value to button. And create one method like below:
-(IBAction)buttonClicked:(id)sender{
int clickedTag = [sender tag];
}
inside that, you will get the Tag of button which is clicked. And you can do according to Tag.
Just set the tag while you are creating the buttons programmatically.
[button setTag:counter]; // if you are creating the buttons in For loop
Cheers.
It sounds like all these buttons probably have the same action, right? Give each button a different value for its tag property. The action can then look at the tag of the object that sent the message, e.g. sender.tag, to figure out which button was tapped. Use that information to figure out what data to display in the next view.
Simple. Set the tag value for all the buttons. Use the sender object to display the values accordingly in your view.

UIButton states

I am making multiple custom buttons that look much like this:
It is a simple button with either the green or gray in the "indicator view". What I need some explanation for is: In interfacebuilder there are four states a button can have; Normal, Highlighted, Selected and Disabled. When I provide images for everything except disabled I thought that normal would be when no touches were made on the button, highlighted is while you hold your finger on it and selected would be when after you release finger.
However I do not think thats right now. I use the touch-up-inside event. Is it correct that I need to set the selected/highlighted etc property on the button?
Thank you for your time.
You might want to set to selected and not highlighted.
Highlight is darkening the button for a fraction when touching the UIButton. UIButton can modify your image automaticaly so usually you don't need to provide a highlight image.
Disabled is when it is disabled.
Selected is when it is selected. You can invert the select flag on touch up inside event to make a state button.
[button setSelected:![button isSelected]];
Yes, you need to respond to the touch up inside by setting the button to highlighted.
Btw, it's "disabled" not deselected, but it doesn't sound like you need that state.

how to recognize which key is pressed custom keypad and which text field is selected

i need to add custom keypad in app.
for that i add the images on buttons like this.
i have 10 textfields in my app.
when ever i press the keys i need to print on selected textfield.
How can i recognize which button is clicked,which textfield is selected.
can any one pls post some code.
Thank u in advance.
Set the tag property of each textfield to a different value. Pass in the textfield as the sender argument to the IBAction. Check the tag of the argument.