IBAction in Xcode 4.5 - ios

Anybody experiencing no response for IBAction touchUpInside in Xcode 4.5, deployment target iOS 5 as well? It works in simulator for me having iOS6, but not iOS5.

I had this same issue because I was using a tap gesture. You should be able to keep your existing code by adding the line below. This will keep your tap gesture from killing any taps on interior buttons and such...
yourTapGesture.cancelsTouchesInView = NO;

Edit:
I have found the solution. I was adding a tap gesture to the view, which was overriding the view's ability to detect a touchUpInside action on any buttons since they are part of the view as well. So what you should do is either remove the gesture recognizer or make it specific to a certain object. For example, I added the touch gesture to the specified part of the view that was not on the subview (I created a new object / outlet and labeled it as such). Still not sure why it's different in 5.1 vs. 6.0, but this should help you.
Original Post:
I am having the same issue. I have a project where buttons on a subview are clickable on version 6.0 of the simulator but not version 5.1. I have some gesture recognizers in there as well but commented them out to see if they were the issue and they are not. The only thing I have found is that the buttons are sometimes clickable on a touch up outside action (even though they are programmed for touch up inside), so I am not sure if maybe Apple changed the eNums for button actions? If I come up with a solution I will be sure to provide it here.

I just created a new demo project. I added a button to a view, handle touchUpInside, built and tested using Xcode4.5 on both deployment target ios6 and ios5 - both worked just fine. Try with a demo project yourself - won't take more than a few min.

Related

Selectable objects on UITableViewCell not responding to user input on iOS14

While compiling a couple of projects with XCode 12 (beta 5 is the latest version at the moment) and running them on iOS14, I've noticed that UIButton, UITextField, and many other selectable objects are not responding to user input when inside of a UITableViewCell.
In some cases, it is possible to work around the issue by bringing the object to the front (object.bringToFront()), but this is not working for all the cases I'm facing. I've also noticed an empty view (layer) on top of the components of the cell when I use the "Debug View Hierarchy" Tool. This view is not present on XCode 11 builds. Is this some new cell configuration that I'm missing? Is there a standard way of disabling this behavior or will I have to be hacky to fix this?
PS: The issues were not present on the same projects when compiled with XCode 11 (or previous), even when running on iOS14.
All the select response issue may caused by adding subview on UITableviewCell. The right way is add on UITableViewCell.contentView, check it first.

Buttons in iOS app don't respond to touches around the edge of the screen

I'm relatively new to iOS development, but I'm having a go at working on some open source code for an old game that used to be pretty popular (Eden World Builder)
I've made quite a lot of progress in cleaning up the codebase, making small changes. But there's an issue I can't seem to fix. Every button in the game will not respond to taps around the edges of the screen. If a button is in the corner of the screen, you will have to tap towards the bottom of the button.
I've tried to move the buttons away from the edges, and they work, but that isn't practical for use. So there's something preventing the edges of the screen from registering button taps for some reason, and it doesn't seem to be anything to do with the button target areas themselves.
One thing I've noticed: This game is currently on the App Store, even though it hasn't been updated since 2015. In the App Store version (Which is built from the same code that I have) the issue doesn't occur. It must be something to do with building it in a newer version of Xcode, right?
Any assistance would be very helpful, this has been frustrating me for weeks now. Thanks
The answer to your first question is most likely either that your button is outside its parent view, or a gesture recognizer is interfering.
If a button extends beyond its parent views boundaries (or any of its higher parents' boundaries), it will still be visible as long as the parent doesn't have clipping enabled. The result is that you will still see the button, but it will only respond when touching the parts that are inside the parent view. You can find this visually by using Xcode View UI Hierarchy found in the Debug Navigator.
If it is gesture recognizers that interfere with your button, there are several solutions that might work. Several are described in the link you got from #Anbu in the comment.
The answer to your second question is that old apps are linked against old frameworks. Even if they run on the latest iOS version, they still pull in older versions of the framework, causing them to (mostly) continue work as before. This is done to keep compatibility with legacy code.
Try adding this to viewDidAppear
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if let window = view.window,
let recognizers = window.gestureRecognizers {
recognizers.forEach { r in
r.delaysTouchesBegan = false
r.cancelsTouchesInView = false
r.isEnabled = false
}
}
}

Swift: Touch not immediately registered for UIButtons located at bottom of UIViewController

I run into a strange behaviour I am not able to solve. If I place a UIButton at the bottom of the UIViewController of the Main Storyboard, touching it is not immediately registered. It takes about 0.5 seconds till the touch gets registered. You can see than from standard UIButtons when they change the text color. I don't have this issue with buttons anywhere else in the UIViewController.
All I did is adding a Vertical Stack View with 15 UIButtons to the Main View Controller of a new App. When I execute the App on an iPhone 6 or iPhone 8 (the actual devices), the lowest button behaves differently. Touching it doesn't change the text color immediately, while it does for all the other buttons.
Did anyone experience the same issue? Is there a way to solve this or did I just find a bug in the framework? I'm using Xcode 9.2 and deployment target is iOS 11.2.
Go to AppDelegate and try adding:
for gesture in self.window.gestureRecognizers {
gesture.delaysTouchesBegan = NO;
}
It will stop the system from checking to see if you are trying to open control centre.

Xcode 8.1 UI Testing twoFingerTap() fails on Google Maps view

Since upgrading to Xcode 8.1 my UI tests that use twoFingerTap() to zoom out on a Google Maps GMSMapView have been failing with
Assertion Failure: Element.swift:135: UI Testing Failure - Unable to find unoccluded area to perform event.
The message preceding that is
Recompute visible frame by excluding frames of occluding elements StatusBar and "the view's identifier"
Anyone have any idea what I should do about that? Tried tapWithNumberOfTaps(1, numberOfTouches: 2) and same thing happens.
NB. The problem is definitely with multi-finger taps only -- doubleTap() and pinchWithScale(2.0, velocity: 1.0) continue to work fine under Xcode 8.1. pinchWithScale(0.5, velocity: -1.0) continues to move origin instead of zooming, which is what it did to GMSMapView in Xcode 7 as well.
I am not sure if you're drawing your UI, or using storyboards. Nevertheless, it doesn't appear that you have the elements drawn to the view properly. Perhaps using constraints you can secure the element to your view.
Ive just upgraded to Xcode9 (beta) and this issue appears to be resolved
Not sure if you already solve your case but It will help if you put Google Map inside another view and then set it's accessibility in storyboard (make sure Accessibility's "Enabled" and "User Interaction Enabled" is checked)
Then you can find it inside otherElements and tap or doubleFingerTap on it.

iOS 9 Segue Causes App To Freeze (no crash or error thrown)

I have been working on this app for months now and from as far back as I can remember I have never had an issue with segues. The code is unchanged in terms of calling performSegueWithIdentifier but since my recent update to Xcode 7 and iOS 9 I have not been able to tack this issue.
I have tried:
Deleting button and creating new button w/ segue link
Using a direct segue from button to view, without the use of performSegueWithIdentifier
Connecting button to new blank viewController
When I press the button, no initial load functions are called on the destination VC (Ex: ViewDidLoad, ViewWillAppear, etc). When I connect it to a blank view, the segue works fine with the same code in place.
Since the code never stops, or breaks, and just seems to "freeze" in place while still running on Xcode I can't seem to even narrow this down to whats causing the issue. I have a similar segue that is also called from another button on the same ViewController that has no issues whatsoever.
Any thoughts on the matter are greatly appreciated!
EDIT: I have narrowed the issue down to the UITextView's causing the problem. Once the Text Views were removed the page loads fine via segue. I wonder what changed between iOS 8 and iOS 9 in terms of UITextView as I will have to remove the text views and completely re add new text views.
So basically the segue was freezing because of the UITextView's I was using in the destinationViewController. The following fixed the issue:
Delete all UITextView's
Add new UITextView's
you must leave the default lorem imposed text and change this programmatically in the viewDidLoad()
This was the fix for me, and from the research I have done on the issue it seems this is a bug in iOS 9 and Xcode 7.
Cheers!
NOTE: Removing the text in the UITextView (or making it longer then ~12 characters) is sufficient to work around it, no need to delete and recreate them. This is fixed in Xcode 7.1.1 and later.
I ran into the same issue and the fixes in this post (Xcode 7 crash: [NSLocalizableString length] 30000) solved the issue for me.
The first is to enable a localisation other than the base for the storyboard (see https://stackoverflow.com/a/32688815/3718974)
The second is to turn off the base localisation (see https://stackoverflow.com/a/32719247/3718974)
I think I have the same problem: I have a UITabelView with cells created from a nib file, when a user tap a cell this method is called:
and when I have the following method prepareForSegue:: the application crashes:
if I delete the line 129 Everything is ok , the method prepareForSegue:: open the right view and the label contactName is shown with its default text.
If I modify the method as follows prepareForSegue:: get exactly what you expect, without having any type of error:
let me know if you also get the same result
Any one who is facing this issue, i solved it by turning off the "Optimize rendering for windows scale" option in Debug of simulator window. I already had tried all of the above answers but could not solve the issue.
In the method in the first viewController where you activate the segue, do you have beginIgnoringInteractionEvents anywhere? If so the screen you segue to will be frozen and will ignore interaction events like you describe. If this is the case you can fix this by adding an endIgnoringInteractionEvents method before your segue method:
UIApplication.sharedApplication().endIgnoringInteractionEvents()
self.performSegueWithIdentifier("editItemToMyGearSegue", sender: self)
I realize this is an old topic, but appears to be still relevant. I was facing the same problem in Xcode 9, iOS11. My UITextViews are embedded inside UITableViewCells. Same symptoms as described here. The tricks with default text and placeholders did nothing for me, but I solved it by turning off the scrolling indicators for the text view in the xib. They were on by default, I guess, though unused.
Edit: this is probably an important detail... the views that were hanging all had an image NSTextAttachment in the attributed string of the text view. I think the image was wider than the available table cell content. With scrolling turned off, they appear to downscale.

Resources