IBAction not getting called for my textfields inside the scroll view - objective-c

I am having a ScrollView which is a child of a View and then several textfields as children of
this ScrollView. I am trying to give IBAction to these textfields via nib and setting the
delegates of the textfields also via nib.The delegate method of UITextField gets called
without any problem,but the IBAction for the TextField is never called. My view hierarchy is
as follows
UIView -->(TopMost Level )
|
ScrollView-->(Child of UIView)
|
Several TextFields-->(children of Scrollview)
All the TextFields are having the same IBAction. I am working on Xcode 4.5 and working on
ARC based project. Any help is greatly appreciated.

Finally I worked around and found a solution my self.
I was declaring IBAction with Touch Down Event which works perfectly fine if TextField is
inside the UIView not the ScrollView.
But when the TextField is inside the ScrollView , the IBAction for the TextField should be
declared with EditingDidBeginEvent.
I don't know the reason behind it though.

Related

Objective-C UIButton in UIView Hierarchy not animating

I have a ScrollView with multiple Subviews and somewhere down there two UIButtons. They are not covered by a different UIView and they are perfectly visible.
The problem now is that the buttons are working, but they are not getting the "pressed" look like all other buttons.
Is there a possibility to trigger that "pressed" animation manually or is there another workaround?
Make sure for those buttons in the Attributes inspector the "Type" is set to "System"

3 programmatically created UIButtons - how to go between 3 UIViewControllers using those buttons with Storyboard?

Playing around with some Objective-C (well, iOS) and have done the following... loaded some UIButtons programmatically into a UIScrollView. That works well. Though I've always just connected UIViewControllers together using control-click and drag. Now I've created buttons programmatically, I have no idea how to go from one view controller to another in a Storyboard because there is nothing to drag from!
I'm not really sure what code to post as such, because I haven't done anything that /nearly/ works or doesn't work as such. I get how to do it with XIBs. But I suppose the question is : 3 UIButtons have been created programmatically and I have 3 UIViewControllers. How do I access those ViewControllers using my UIButtons?
Thanks
In the Interface builder view control click and drag from the viewcontroller icon under the first view controller, to the middle of the second view controller. A segue will be created, selected the appropriate type.
Now select the segue and in the inspector give it a unique identifier (say 'myNewSegue').
Now in your first viewcontroller you can create a method that has the following code:
-(void)myButtonAction:(id)sender {
[self performSegueWithIdentifier:#"myNewSegue" sender:self];
}
And add this method as a target action to your button:
[myButton addTarget:self
action:#selector(myButtonAction:)
forControlEvents:UIControlEventTouchUpInside];]
A segue doesn't have to have a button at the leading end of it; you can instead draw it from an entire view controller to another. You can also give a segue an identifier, a string that's used as a name for that segue. Once you've done that, you can programmatically trigger that segue by calling -performSegueWithIdentifier:sender:.
To actually call -performSegueWithIdentifier:sender:, though, you'll need to connect the button to a target and action. If you've never done that, read the Event Handling Guide for iOS in your documentation.

Subview of Scrollview doesn't register touch events

I'm struggling with this problem, and although there are quite some threads on this issue I've not figured it out yet.
I want to load a button into a subview of a scrollview. If I test this subview alone, the button works fine. Also, when I add the button to the scrollview directly, it works fine. But the two combined I don't get any touch event on the button.
My view hierarchy:
UIScrollView
UIView
UIButton (A)
UIButton (B)
So button B works fine, A doesn't.
I've tried messing around with the attributes like Cancellable Content Touches, but so far no luck. I'm loading the subview from the storyboard with:
ViewVC *viewVC = [self.storyboard instantiateViewControllerWithIdentifier:#"ViewVC"];
From the posts I've read, this should just work, so either I'm missing something vital, or I've messed up some attributes along the way. Should I use a delegate to pass the events, or should this be done automatically?
Give your views some colours, and check if one of them is obscuring the other preventing it from being touched. Maybe you UIView is overlapping your UIButton(B), preventing it from being touched.
How are you sure you're adding it?
Make sure you're calling addSubview: on your UIScrollView with your subview as the parameter?

UIBarButtonItem not responding to touch

I don't know what wrong but my UIBarButtonItems in a UIToolBar aren't responding. I have a splitviewcontroller and the bar button item that is implemented with the template isn't responding either. It literally doesn't even change it's tint when click. I created a new UIViewController , presented it as a modal view controller. The vc has a toolbar and a barbuttonitem, and the bar button item is hooked up to an IBAction. That's not responding either. Is there something I am missing here?
Thanks.
Well by default in the viewcontroller.xib should have touch enabled, but just in case you should check the properties inside the viewcontroller of the UIBar and see if buttonpress is enabled or whatever option for interaction is in the xib

No UIControls responding to user events

I am creating an iOS app without using Interface Builder and I seem to be missing something vital whereby the controls I am creating (UITextField, UIButton, etc.) are not responding to touch events.
Here's my view hierarchy:
UIWindow->UIView->(UITextField, UIButton)
I am able to create the above hierarchy and everything is showing up fine on the screen, but tapping on the UITextField or the UIButton do nothing. I also tried adding some UIGestureRecognizer subclass instances to the UIView to no avail.
I am able to call becomeFirstResponder on the UITextField and the application starts with the keyboard up and able to receive input. However when the keyboard is dismissed the interface goes back to its "dead" mode.
What am I missing?
I was calling init on my UIWindow instead of initWithFrame:. For some reason everything was drawing correctly but the UIWindow was not responding to events because every user tap was outside the bounds of the zero-size window.