Hi, I encountered a similar issue in my app: My app shows and hides an edit area (text field + other controls) when the keyboard hides and shows. The iPad floating and split keyboards presented a problem because as mentioned, they only send frame change events.
I track the use of the traditional iPad keyboard by watching UIKeyboardWillShowNotification and UIKeyboardWillHideNotification events, and for floating and split keyboards, this is my solution when I get a UIKeyboardWillChangeFrameNotification notification:
// n is NSNotification * from UIKeyboardWillChangeFrameNotification
NSDictionary *keyboardInfo = [n userInfo];
CGRect keyboardFrameEndRect = [[keyboardInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
NSUInteger animationCurveOption = [[keyboardInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];
if (CGRectEqualToRect(keyboardFrameEndRect, CGRectZero) || // Floating keyboard is HIDING or BEING DRAGGED by the user
keyboardFrameEndRect.origin.y >= self.view.frame.size.height) { // Split keyboard is moving off screen
if (animationCurveOption != 0) { // When animation curve is zero, the keyboard is being hidden. (Otherwise, it's being moved)
// TODO: FLOATING OR SPLIT KEYBOARD IS HIDING
}
} else {
// TODO: FLOATING OR SPLIT KEYBOARD IS SHOWING
}
Post
Replies
Boosts
Views
Activity
Hi Demitri,
I did another deep dive into the problem and can share a resuable control and test harness:
https://github.com/Tinrocket-LLC/TRMetalImageView
It's fast, because it only draws the visible region of the scroll view's .documentView, and handles all the edge cases I've encountered in deploying this control, in my commercial apps, over the past two years.
Hope this helps!
John
Hi Demitri,
I was in the same position: I shipped an app last year that embedded a MTKView in an NSScrollView. To work around the texture size limit, I set the maximum zoom on the scroll view to never exceed the metal texture limits.
This year, I implemented what you are now trying to implement: I have an NSScrollView that's synced to a metal view. The scroll view's content is set to the image size and handles all the panning, zooming, etc. The metal view is never resized; it sits below the scroll view and is updated when the scroll view changes. This was a bit of work to implement, but the results are very good.
I took the time to create an intermediary: I first created a Metal-backed view (an NSView backed by a CAMetalLayer) that can display a arbitrary CIImage. I then added scale and offset settings to this view, which perform a CIImage transform and CIImage crop. This essentially creates a region of interest for the CIImage, and just that region is rendered to a Metal texture.
Once this intermediary control was created, it was simple to sync it with the NSScrollView.
Happy to go into more detail, if required.