I have a "Clear" button. It clears 2 text fields back to being empty.
When the user clicks the "Clear" button once, I want it to change or become another button that adds back what it cleared. Like a "Redo" button.
How can I go about doing this? So far this is what my "Clear" button does:
- (IBAction)clearButton:(UIBarButtonItem *)sender {
_inputTextField.text = #"";
_outputTextField.text = #"";
_characterCount.text = #"0";
_characterCount.textColor = [UIColor blackColor];
}
I used to be able to use shake-to-undo, but after updating to iOS8 and xCode, no matter if I shake it, the redo menu does not pop up. It used to back in iOs7, but all it did was crash the application. Is there a way to fix this? I have it enabled but it just doesn't show up anymore.
Please don't berate my question. I tried searching but couldn't find it for a toolbar for iOS.
Hi I have create a new project on your requirement , have a look and reply :
https://github.com/ksbani/StapperRepo/archive/master.zip
Related
I am implementing simple UI for URL checking. For this, I used textField and button objects.
When I run the program first time, textField and button will work fine but when I click on the done button on the keyboard then the keyboard is dismissed. Now I want to edit the textField and when I am trying to click on textField it is not clickable or not showing the keyboard. same thing happened to the button, next button is also not clickable.
Here is the code I wrote for the button action
- (IBAction)urlNextButtonAction:(id)sender {
[self.urlTextfield resignFirstResponder];
[SVProgressHUD showWithStatus:#"Verifying URL"];
[self URLValidationMethod];
}
Please check this video you will understand the problem very easily
This is the ViewController screenshot from storyboard
There could be several issue with this..
Check either Textfield delegate might not be or properly set.
Try to debug textfield delegate methods are they working.
it would be helpful if you show what you have written in keyboardShouldReturn method.
It seems like the problem is with the SVProgressHud. You should remove it as soon as you task is completed by calling [SVProgressHud dismiss] or else it will block the UI.
I have a UITextField that brings up the keyboard and right now, once you tap "Go", you can still edit the text field while things are loading (more importantly, you're interacting with the keyboard and can still press the return key again, which creates a bunch of problems).
I've tried [[UIApplication sharedApplication] beginIgnoringInteractionEvents], but you can still interact with the keyboard. I don't want to hide the keyboard while it loads because if the entry is invalid, the user will need to use the keyboard again. Any help is much appreciated.
I think you're handling this the wrong way. What I would do is this:
Once the user hits "Go" and the loading starts, hide the keyboard and disable user interaction on the textfield.
If there is an invalid entry, enable the textfield again and bring up the keyboard.
As far as I know, if the keyboard is in view, it cannot be disabled (And for good reason, thats poor UI design. )
you can try like this,assume goClicked method is fire method when you clicked on "GO"
- (void)goClicked
{
[self.view endEditing:YES];
[yourTextField setUserInteractionEnabled:NO];
//loading things code
//when loading completes or loading fails
[yourTextField setUserInteractionEnabled:YES];
}
I have a screen in which the user is doing some actions.
When clicking the back button, I want to stop and show an alert to confirm this step.
I have 2 options:
Leave the native back button: < Prev screen and catch the -(void) viewWillDisappear:(BOOL)animated. when I'm doing that, It is too late to go back. I can't stop the back action, can I?
Replace with custom button. That's the easy solution, except I don't have the < on the button... Adding this sign as an image looks too cumbersome.
Does anyone have an idea how to solve this?
The right way is to create a custom UIBarButtonItem with the right type. Using an image is not painful at all.
And no, there is no use trying to prevent the pop action on UINavigationController. Also mind the InteractivePopGestureRecognizer as of iOS 7.
UIButton *button= [UIButton new];
//customize your button here
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc]initWithCustomView:button];
self.navigationItem.leftBarButtonItem = leftBarButton;
customize your button with your title etc...
I'm using KIF to automate my app, and I'm trying to automate typing something into a UISearchBar and searching for it. Unfortunately I couldn't find a satisfactory way to do that by programmatically clicking on the search button after I've entered my search text.
So instead, I considered simply using KIF's tapScreenAtPoint method. The problem with that method is that it does the following:
CGPoint windowPoint = [window convertPoint:screenPoint fromView:nil];
view = [window hitTest:windowPoint withEvent:nil];
It's expecting the tap to actually touch a view.. and since the keyboard is obviously not a view this test won't be able to trigger the search button on the keyboard.
How can one programmatically tap a button on the keyboard? I think this would be very useful for any automation-test suite.
It sounds like you're trying to tap the "Search" button in the keyboard. The accessibility labels on return keys don't follow any sort of sane pattern. Looking in the accessibility inspector, you'll see "SEARCH" but that may not be consistent on all OS versions.
Update
You can trigger the search button by adding \n to your enterText...
[tester enterTextIntoCurrentFirstResponder:#"query\n"];
The correct way is to use:
[tester clearTextFromAndThenEnterText:#"sample test" intoViewWithAccessibilityLabel:#"SearchField"];
[tester waitForViewWithAccessibilityLabel:#"search"];
[tester tapViewWithAccessibilityLabel:#"search"];
Accessibility label for the return key is "search" in this case, you can verify it by using accessibility inspector app.
But be careful, the 'return key' (search/done/return/whatever) won't be pressed if you are adding a text that ends with cap letters, for example:
"sample TEST"
The 'shift' button will be pressed and the 'return' button won't, even if you try to use the "tapScreenAtPoint" method.
It happened to me and got me crazy for a long time until I figured out what was actually going on.
I know about self.navigationItem.rightBarButtonItem.enabled = NO, but how do I make a UIBarButtonItem appear disabled but actually detect when the user taps it? I want to do this in case I want to alert the user what is incomplete.
The way i'd do it is not disable it, but when its 'disabled' set another bar button item there with a disabled looking background and no alternate image for the tap event. Then when it is tapped, show an alert view to tell them that it isn't available:
- (void)init
{
[self setDisabledBarButtonItem:[UIBarButtonItem alloc] initWith...];
[disabledBarButtonItem addTarget:......];
[self setEnabledBarButtonItem:[UIBarButtonItem alloc] initWith...];
[enabledBarButtonItem addTarget......];
}
- (void)timeToDisableBarButtonItem:(id)sender
{
[self.navigationitem setRightBarButtonItem:disabledBarButtonItem animated:NO];
}
- (void)timeToEnableBarButtonitem:(id)sender
{
[self.navigationitem setRightBarButtonItem:enabledBarButtonItem animated:NO];
}
Good UX practises state however that you shouldn't need to tell your user that it is disabled, they should be able to tell without an alert. Easier said than done of course :)
Would love to see a cleaner solution than this, but its the only way I think your going to get it to work.
Hope that helps :)
I had a similar problem, except I was trying to make a disabled button look enabled. I found a much nicer solution that is available in iOS 5.0 - you can use setTitleTextAttributes:forState to control the appearance of your enabled (or in my case, disabled) state, as well as many other states.
API reference:
https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIBarItem_Class/Reference/Reference.html#//apple_ref/occ/instm/UIBarItem/setTitleTextAttributes:forState:
In most cases you won't want to do this. However, in my case it proved necessary. I have a toolbar button that is a document title, and pressing it while in edit mode allows brings up a UITextField to edit the title, but in run mode the title should not be editable while still looking like a title, rather than a disabled button. By changing the text color to match my enabled state, I achieved the look and behavior I wanted without having to swap the button or the action out (and consequently have to synchronize my title text across three places instead of two).