Xcode: Keyboard interrupts a timer function - ios

One of the screens of my iOS app has a textfield and an image which is smoothly rotating around and around via a NSTimer. When I tap the textfield and the keyboard pops up, the rotating image stalls for a fraction of a second. I assume this is because the keyboard code interrupts the execution of the image-rotation code. To solve this, will I have to learn about threading? Or is there a simpler solution?

Related

Keep iOS textView on top of keyboard after app resumes from background

I have an iOS 9+ app with a textView that, when clicked in, opens the keyboard and slides up with it. It slides back down when the keyboard is dismissed. So far, so good.
When the app is sent to the background while the keyboard is open with the textView on top of it, then when the app resumes the textView is sent back to the bottom behind the keyboard (after a split second), but the keyboard remains open. The scenario is explained in this other SO question.
Thanks to that question I have a watcher and can run this:
#objc func willEnterForeground(_ notification: NSNotification!) {
view.endEditing(true)
}
...and that works to hide the keyboard "almost" seamlessly.
But I really want the textView and keyboard to be exactly as they were when the app was sent to the background. What might cause the textView to go back to its baseline position? I'm running through the view controller with breakpoints and, so far, have had no luck finding anything.
EDIT: You don't actually have to send the app all the way to the background. Just starting the touch gesture to send the app to the background (dragging the virtual home bar up) and letting go will remove the textView (also removes an inputAccessoryView if there is one).
EDIT: Here is the slow motion screen recording demonstrating the issue:

SpriteKit animation stops unexpectedly

I'm trying to debug a very strange behaviour of SpriteKit animation. It's quite easy to reproduce:
Create a new Game project in Xcode leaving all the options unchanged.
Open GameScene.swift and change line #23 from label.run(SKAction.fadeIn(withDuration: 2.0)) to label.run(SKAction.fadeIn(withDuration: 0.2))
Connect your phone and start a debugging session, observe how the text (Hello, World!) fades in and appears in full brightness. Well, so far, so good.
Stop the application from Xcode and start it again clicking its icon on your phone.
Observe how the text, although visible, is not faded in completely.
I found this trying to understand why my animation just stops half the way when my application loads. I assume that somehow the view stops refreshing if some initialisation step is longer than the animation but I don't know how to fix this. I also noticed that if you click on the screen it refreshes and the animated view appears in the final state.
iOS version: 10.3
I've discovered a serious issue with iOS11 and SpriteKit. The Game Scene during the transition is getting paused automatically (but only in iOS11).
After transitioning to the scene run
myScene.isPaused = false
and it should fix the issue, and should have no adverse affects when the game is run on iOS10

iOS Program Flow After InputAccessoryView

I have an unreasonable delay (3 seconds) in my iOS application between the time a user taps a control and when the keyboard is shown.
To reproduce this, I give textfield #1 focus then quickly resign the keyboard with the keyboard resign button and tap textfield #2.
If I tap between the two fields without manually resigning the keyboard I don't see this delay.
I've tried debugging the app to see the program flow but I'm not good enough with the debugger to actually trace anything, I always end up in assembler.
I know that the delay happens after textFieldShouldBeginEditing returns and after inputAccessoryView returns, but before a kUIKeyboardWillShowNotification is fired. My question is, what happens between these steps? What does the program flow look like between the call of inputAccessoryView and the notification for UIKeyboardWillShowNotification?
I believe that if I could just figure out what IOS is executing in this delay I could come up with a work-around.
I honestly believe this was an IOS 8 problem. After changing the target to 9.3 this issue seems to have all but disappeared.

How can I detect from iOS Keyboard extension if user scrolled up the Control Center?

I develop an iOS Keyboard extension, and I'm using scroll gestures on keyboard. Sometimes when using the keyboard I scroll up the control center and my keyboard stops working fine. Is there any way to detect if control center become visible, or invisible?
You can't do it directly. The most you can know is that your app was deactivated and then activated again. It could be because of the control center, it could be because of the notification center, it could be because a phone call came in, it could be because the user went into the app switcher and came back again...
Here is the possible work around you can try:
It is the UIWindow subclass to enable behavior like adaptive round-corners & detecting when Control Center is opened. This UIWindow subclass does probably the thing you want. You simply subscribe to an NSNotification and can react to the user opening Control Center. Detailed instructions and setup on Github
https://github.com/aaronabentheuer/AAWindow
[AAWindow: The way this is accomplished is by using a combination of NSTimer and overwriting sendEvent in UIWindow to receive all touches without blocking them. So you basically receive all touches check if they are near the lower edge of the screen, if yes set a timer for a half a second and if during this timer is running applicationWillResignActive is called you can be almost certain that ControlCenter is opened. The time has to vary if there's no statusbar, because then the app is in fullscreen and it can take the user up to 3 seconds to launch Control Center.]
Hope it would help you figure out the exact solution to your problem.

UIView Animation Freezes

I'm implementing drag-keyboard dismissal (like in the iPhone Messages app) manually because UIScrollViewKeyboardDismissModeInteractive doesn't seem to work with a text view inside a toolbar above the keyboard.
It works in portraint mode, but in landscape orientation, sometimes when I animate the toolbar (which is actually just a UIView) & keyboard, they freeze. But, they did animate because I checked using breakpoints that the animation code ran and when I tap on the screen where they're supposed to be, I get the correct reactions (like keyboard keys pop up, etc.).
I'm using the old style of animations beginAnimations:context: because this is how to mimic the keyboard animation in iOS 7.
This seems like an iOS SDK bug. How do I fix this?
I was sometimes (when the pan velocity was large) using UIViewAnimationCurveLinear instead of the curve from the keyboard notification's userInfo. I took that condition out so that I always use the curve from the keyboard notification's userInfo and things seem to be working fine now.

Resources