touchesBegan not called on UITextField - swift

I have created a simple test project with a single UITextView and the touchesBegan method in the view controller. For some reason, the UITextView is not responding to touchesBegan.
Things I have tried:
Alpha is set to 1
User interaction is enabled on the view and the UITextView
Delay Touch Down is unchecked
The background is set to a solid color
I found similar questions in several places, but none of the solutions have worked.

While it seems like others have successfully gotten touchesBegan to work on a UITextField in the past, nothing seems to be working now. Instead, I simply added textFieldDidBeginEditing and canceled the animation from there. Problem solved.

Related

Strange issue with numeric keyboard losing custom UIButton when it finishes displaying

As hacky as it seems, I am using this method to add a done button to my numeric keyboard:
UIKeyboardTypeNumberPad without a done button
I toggle the slow animation and it looks like this while it is still animating and not quite done:
But then, when it finishes loading, it looks like this!
The UIButton I am adding just disappears! I subscribed to UIKeyboardDidShowNotification and filter through the subviews and can see that by the time the notification is fired, there is no longer a UIButton as a subview of the keyboard.
I tried turning off ARC for the file but still no luck.
Any ideas as to what might be causing the UIButton to vanish? The button is a STRONG property btw.
Thanks
please, can you check again, maybe you have omitted something.. https://dl.dropbox.com/u/19438780/KeyboardExtension.zip
Another tutorial/example for iOS6: http://ofanyuse.wordpress.com/2012/11/09/an-elegant-solution-to-adding-a-uibutton-to-the-numberpad/

UISlider thumb stops dragging

I have a UISlider in a view, in a typical detail View Controller. When I touch the slider's thumb, I can drag it to the left fine, and once I've dragged it left, I can continue to drag it wherever I want, but when I drag it right, it moves a few pixels and then the drag stops.
I read at UISlider only slide a small distance that it may be related to gesture recognizers, but I don't have any recognizers active in this view. I've tried temporarily removing any recognizer that might interfere, but that didn't help.
I don't have any sample code to include because there's really not much code involved in the case I'm having trouble with. I have a UIViewController subclass that has a UISlider on it, and I have an IB-generated action for the "Value Changed" event. This fires, and as I said, I can drag the slider left, but not right.
I tried changing the action so all it does is NSLog the slider's value, and that doesn't help.
I expect the problem is some interaction withs something else in the app I'm working on, but I'm not sure where to look. I'm looking for some ideas as to what could be causing this.
Update
So I found the problem. It's a bug in iOS 5.1, described in iOS 5.1 swipe gesture hijacked by UISplitViewController - how to avoid?.
I tracked it down by enumerating all the gesture recognizers (by walking the view hierarchy from self.view.window and dumping them) and then selectively removing them, then Googling on the one that ended up causing the problem. Pain in the butt. Leaving this here for the next victim.
I posted the answer as an update to the question, but in a nutshell, it's an iOS 5.1 bug. The pan gesture recognizer for the split view controller is interfering with the slider. My workaround is to disable that recognizer.
You are probably trying to increase the value of the slider to something greater than 1. You need to enter a float between 0 and 1, such as 0.46.
Look through the part of the code where you update the value and check that.
Short answer:
Try setting slider's propery continuous to NO.
Long answer:
I encountered a similar problem: slider's thumb would not move on iPad 5.1 Simulator. No problems on iOS 6 though.
In my case, I was setting slider's minimumValue and maximumValue to some other values in code. The problem disappeared after I set continuous property to NO. The relevant fragment of code:
self.precisionSlider.minimumValue = 0;
self.precisionSlider.maximumValue = 15;
self.precisionSlider.continuous = NO;

Label of UIButton appears intermittently inside a UITableView

I have a UITableView with some data. One of controls is a UIButton, with a label assigned. So, in rare cases, when I push the UITableView screen, the buttons appears without label. After I scroll the UITableView or rotate the device, the label appears.
I put a NSLog entry inside the drawRect method. And It's not called in some cases.
Some advices?
Thanks
i found same problems that some methods rarely not called. make sure delegate is properly set and then check the result
After analyzing my code I saw some characteristic that caused the problem. The process of construction of my screen was occurring in a different thread of the events thread. So, I fixed this and everything is fine now.
Thanks.

Why won't UITableView 'Auto-scroll' when editing UITextField (in UITableViewCell)? (iPhone)

I have created a UITableView that is of type UITableViewStyleGrouped. I have then created several different sections with a few rows in each. Within each of these rows I have created a custom UITableViewCell that contains a UITextField. I also have one UITableViewCell that contains a UITextView.
I have also implemented a UIToolbar that appears on top of the UIKeyboard that allows the user to move through the UITextField's by pressing previous or next.
The issue I'm having is two-fold:
I need the UITableView to scroll so that when the next UITextField (or UITextView) becomes the first responder it is visible (even with the keyboard being displayed).
When a UITextField (or UITextView) is selected (without using the previous and next buttons) is should adjust so that the field is visible above the keyboard.
I have looked around at lots of different tutorials however none of them have resolved my issue. Any help you could offer would be hugely appreciated.
ADDITIONAL INFO:
I'm 100% certain that my app used to do all of the above automatically, however I seems to have stopped doing it now and I don't understand why. Is there a reason why this may of happened? Is there some function or something that I may have changed that would destroy this behaviour?
Probably no use to original poster now, but those having an issue like this where it once did work and then stopped...
check you don't have a:
- (void)viewWillAppear:(BOOL)animated
in your UITableViewController subclass!!!
using viewWillAppear in a UITableViewController breaks the "automagic tableView scrolling up when keyboard appears" behaviour.
I only found this by comparing laboriously an old version of a project where it did work with my latest source where it had stopped working.
Check out TaggedLocations sample code from apple. It does the same thing without any extra manipulation.
The key is that your viewcontrollers are following the standard. i.e you are NOT having container viewcontrollers such as UINavigationController within UIViewController.
You have to update tableview Frame yourself programatically...
and i am 100% sure that if you are 100% certain that your app used to do all of the above automatically ...than it is not your app.
Check the docs..here is the link
https://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/ManageTextFieldTextViews/ManageTextFieldTextViews.html#//apple_ref/doc/uid/TP40009542-CH10-SW1
You will have to register for keyboard notifications..and then update your tableview frame.
And for next and previous.. you have to programmatically check which textfield became active..and then set the frame accordingly.

IPhone UIButton doesn't respond in a UIScrollView

I'm an iPhone dev newbie, and I'm having a problem slightly similar to a few posts I read around here, but none of them seemed to help.
I have created a UIScrollView, with a UIView as its content (a subview). During runtime, the UIView is populated with labels and buttons. Everything looks fine, scrolling works perfectly, but the UIButtons never fire when pressed, no matter what I do. I've tried many combinations of properties suggested here, to the best of my understanding, but still nothing worked. I'm afraid I might have misunderstood something about the mechanism.
I should mention that everything is done in code (no IB).
Any suggestions?
My bug (written in the comments of my question) was not setting the frame of the contentview that was the parent of all buttons. The result was strange - I could see the button subviews (which was why it took me a while to find the bug) but could not click on them. oops!
This also may happen, when your custom UIView userInteractionEnabled is NO (default is NO).
try [btn becomeFirstResponder];