UIButton selected content only when touched - ios

Is it possible to see the selected state content of an UIButton only when I'm touching it?

When you're touching a button, the button is highlighted. Call setTitle:forState: to give the button the normal title (UIControlStateNormal), and call setTitle:forState: to give it the highlighted title (UIControlStateHighlighted). Now you'll see one title normally and the other title when you touch the button. The same thing for the other button features, like setImage:forState:.

Related

Change ToolBar Title dynamically on click events in Fragment on Xamarin android?

First let me explain something, so you guys can understand better my problem:
I'm using Toolbar and i have a Fragment called Location Fragment where i have 6 floationg action button vertically .
When you click on one of the floating action button some action like geofence,live tracking,current location etc are performed on the same map fragment.
So my problem is that when i click any of the floation action button ,like when i click geo-fencing floation action button the title on the tool bar should change with the geofence title..In this way for all the Floating action button the title of toolbar should change. in my case the title of the tool bar is not changing .
I have tried to use setTitle or this.Activity.Title="Geo-fence" on the click method of Floating action button,but still it remains same title .
Change ToolBar Title dynamically on click events in Fragment
In your Fragment, add the following code in your click events :
((AppCompatActivity)Activity).SupportActionBar.SetTitle(Resource.String.YourTitle);
this.SupportActionBar.Title = "Your Title";

How to set focus from one UIButton to Another UIButton in UIToolbar Done Button

I am working with iPhone Application with creating single object multiple dynamic button in UITableView. And when user will press button every time UIDatePicker will open to select date. So Is is possible to move focus from one UIButton to another UIButton after date selection. I am explaining you in detail as follows:
I have create UITableView with single object Multiple Custom UIButtons. When user will click on all this button the UIDatePicker will show with Next and Cancel UIToolBar. When user select date from datePicker and press Next button i want focus or select for the next UIButton to give facility to select date from datePicker for another button. Like flow without removing view for transaction.
So is it possible to Focus on another button after pressing Next button to another button.I googled around but could not find any solution for this.
Please help me for this.
Yes You can.. Perform following steps:
Set Different style for your buttons for Highlighted state.
Give a unique tag for each Button.
Lets say you have 5 buttons with tags 0 to 4. In your TouchUpInsideEvent write this,
(IBAction)onButtonClick:(UIButton *)sender
{
for(UIButton * btn in myButtons)//Mybuttons is outletCollection of buttons
{
if (btn.tag == sender.tag + 1)
{
[btn setHighlighted:YES];
break;
}
}
}
If it does not work with Highlighted state, you can try with Selected state. (I think it will work with selected state only .. :))

How to select a UITextField without showing UIKeyboard

I am wondering if there is a way to use a UITextField programatically (i.e. use buttons as inputs) so that you can select a UITextField but not show the UIKeyboard, then when you select a UIButton it would assign a string value to the currently selected UITextField.
I don't really know where to start.
I think you can visually change the appearance of the text field (for example add a blue border), let the user feel it’s “selected”. Then you just modify textfield.text when user presses button.
Or alternately, you can create a customized keyboard. There are many similar questions.
It seems that you don't really need a text field (e.g., edit/select text, etc.), but a "button that stays highlighted" instead. Then, you can programmatically change the button's title label to the specified string when the user taps the 'proper' buttons.

UITableView Editable Cell 'De-Selection'

My application has a UITableView which is editable to be able to delete items. When a user taps the red circle on the left of the cell it reveals a red 'Delete' button. When that 'Delete' button is tapped I am displaying a custom confirmation dialog. If the confirmation is true then deletion proceeds normally. If it is false I want to automatically go back to the state before the red circle was tapped. I have tried setEditing: but it removes the circle completely. The other two methods are setSelected: and setHighlighted:. They don't make any change. Is there a way to do this?

How to display red "Cancel" button in UITableViewCell?

I am building a custom UITableViewCell which will be displayed while the user is downloading data from a web service, and which will include a "Cancel" button to allow them to cancel the URL connection. I'd like to emulate the look-and-feel of the "Delete" buttons which are displayed in the table editing view, like this:
How can I create such a red button which says "Cancel" instead of "Delete" in my custom UITableViewCell? It appears that the only type of button I can put in a UITableViewCell is a regular UIButton (UIBarButtonItem won't go anywhere except a UIToolbar), and Interface Builder doesn't give an option to create a red Delete-like button as a standard style.
In the end, I just had to create my own custom UITableViewCell, and use some Photoshop magic to figure out how to make a button that looks exactly like the iPhone Delete buttons, but saying "Cancel." It didn't take that much time.

Resources