Tap not working if SVG Image inside UIControl - ios

I am writing an iOS App in Swift 4.
I need a custom button with SVG image inside it.
So, I added UIView in Storyboard scene > Changed it to UIControl as custom class > Traits: Button and User interaction Enabled.
Then I added SVGView (Macaw) inside it, Constraints 0,0,0,0 and unchecked all of its traits.
The issue is this button isn't taking any tap (TouchUpInside) gestures.

check is user interaction enabled for the image?

Related

AirPlay Button Custom Sizing

I have an Airplay Button which I have created by subclassing a UIButton to AVRoutePickerView in Storyboard. It's showing the button and also showing the view when tapped. I am unsure how I can change the size of the icon though. Have I created the Airplay Button incorrectly or am I just missing something?
I don't think you want to use a UIButton. An AVRoutePickerView is a UIView, not a UIButton. It creates a UIButton and inserts it as a subview of itself. That's the button you want to resize.
You can access AVRoutePickerView's button by doing this hackery:
let button = routePickerView.subviews.first(where: { $0 is UIButton }) as? UIButton
You can then experiment with changing its frame size... maybe directly or via constraints.
Just beware that this hackery isn't future-proof. Apple could change how it manages the button in the future.

Xcode scrollView that changes its y position using Swift 2

Here's my setup: I have a ViewController that contains an image(button). This button takes the user to another viewController using an #IBAction func (tab controller tab). However, I also want a scrollView on the initial ViewController, just under the image button.
What I'm trying to achieve is the ability to scroll content on top of the image button as if it were another page on top of the image button. As the user scroll back down, the image button is revealed underneath the scrollView and is clickable again.
I can't seem to find a solution anywhere online. My scrollView is either fixed below the image button, or covers the image button rendering it unclickable.
Here's a screenshot
take a look at the demo project i set up:
https://github.com/slotti85/ButtonAndScrollView
i...
put the scrollview all over the screen (also over the button),
set up a contentInset to make the button visible initially,
subclassed UIScrollView and
overrode the pointInside function to make the scrollview forward a touch if the "transparent area" is tapped.
hope it helps!

Custom subviews in iOS Keyboard

How can a custom subview be added to the iOS keyboard for an app, not global using the custom keyboard?
I would like to add functionality to the keyboard in an app, such as stickers and an additional subview in between the text input area and the top of the key subview.
Should a new keyboard be created from scratch? Or can the keyboard be extended?
How are the custom subviews hooked up to a controller for handling? E.g. facebook or viber have stickers that can be selected, how are these subviews managed and connected to the VC?

Custom iOS Keyboard

I want to add a keyboard icon to the bottom left grey square on UIKeyboardType.NumberPad. How can this be done?
Some ideas I have went through.
class that conforms to UITextInputTraits I couldn't figure out what was required to satisfy the protocol.
UIButton above the keyboard
subclass of UIView and not use a keyboard at all. This one seems the hardest.
If you want to show a custom view in the bottom, you have to add a subview to the keyboards window view so it overlays the keyboard.
The Keyboard is shown on a separate window UIRemoteKeyboardWindow
Run this code AFTER the keyboard gets shown:
let view = UIButton(frame: yourFrame)
UIApplication.sharedApplication().windows.last?.addSubview(view)
It's the cleanest solution that requires the least work.

UIButton lazy to change state from normal to highlighted

I have a strange behavior. With Interface Builder I have defined the normal image and the highlighted image state for UIButton but if I tap quickly the button remains in the normal state (but the associated selector is call). The button change state only if I perform a long tap on it.
But if I tap quickly the image doesn't change and the button seems disabled.
If can help I have a view controller with a scroll view attached on it. On this scroll view I have attached a view (that is very long) realized with interface builder.
Ideas ?
This is a feature of UIScrollView. It prioritizes scrolling instead of the button contained within. By setting delaysContentTouches = NO on the parent UIScrollView you should get nice, responsive buttons. However, you won't be able to scroll the parent UIScrollView while touching those buttons.

Resources