I have a UIWindow with a hard-coded UIView inside. I'd prefer to keep it that way, is there a nice way to rotate an already visible keyboard? This question asks the same thing, so I guess I'm really asking if the API used by UIViewController to rotate the keyboard is private API. I'm not going to use it if it is, but I'd still be interested in what it is. And how you found out. Thanks!
UIViewController handles the rotation for your, you really should use one. Don't try to reinvent the wheel, stick to the best practices and you will avoid a lot of unnecessary work.
https://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/AppArchitecture/AppArchitecture.html#//apple_ref/doc/uid/TP40007072-CH3-SW18
The UIViewController class is the base class for all view controller
objects. It provides default functionality for loading views,
presenting them, rotating them in response to device rotations, and
several other standard system behaviors
Related
I've been wondering for quite some time how Instagram implemented their text editor transition:
On a first guess, I'd say they are performing both the text editing and the "movement" on the same UIViewController, but at the level of complexity they have, they must have found a way to make the transition from VC A to VC B, where VC B does the entire text editing.I'm starting to think that the VC A (movement VC) is holding a "snapshot" of the UITextView, where VC B actually hold the object (then the user can edit it).
I'm not looking for a drag & drop code solution. I'm trying to think out loud about what is the possibilities to implement the same behavior they have, in terms of correct architecture and user experience.
Thank you for your time,
Roi
This kind of problem is best solved using a custom class derived from UIViewControllerAnimatedTransitioning. I've done it before with logos transitioning from one view controller to the next. The official docs are here: https://developer.apple.com/documentation/uikit/uiviewcontrolleranimatedtransitioning and there are numerous examples of how to create a class on the internet.
I'm trying to implement 3D Touch feature that presents a summary of information (like Peek). But I don't want that it pops. I just want to preview the information like contacts app does with contatcs:
It only presents an UIView and doesn't deal with two levels of force (peek and pop).
How can I do something like this?
Ps.: I don't want to deal with long press gesture.
Introduction
Hello
I know this is a bit to late, probably, but in case someone else stumbles upon it: I certainly believe it is possible and I don't think its a "native behavior for contacts". Although it would not be as simple as the UIKit api for peek pop views. You would need to:
Steps
subclass UIGestureRecognizer (perhaps it may work with the UITapGestureRecognizer also), and register UITouches and use their force property.
Setup a UIViewController with transparent but blurred background around the edges (together with a modalPresentationStyle .overCurrentContext if i recall correctly), with your desired content in the middle (much like the peek view). Then add a UIPanGestureRecognizer to the center view for dismissal/sliding up the buttons.
And then create a custom animation transition for that UIViewController to be triggered once the force property of the registered UITouches from the subclassed UIGestureRecognizer is high enough. And then reversed once the force property gets low enough.
Concluding notes
I believe this is a bit of a tedious task and there might be a simpler way. For example, a simpler way using a 3rd party library for long pressure gestures (that registers size of the touch), but it would not give the same feel.
I want to make a pretty interface. So after reflexion, I decide to make a pattern with to axes but with some essential points. The red screen is the primary screen, all start by this one.
We can only make this two move : red to another color and another color to red. And change are made with GestureRecognizer.
I also want to switch view by seeing the two at the same time. Obviously, it's following my finger and I can stay in this state.
Do you think that 5 viewController witch are all load at the start and we came to these with pretty segue (maybe custom) is possible ? And if yes, do you have an idea of how to make this ?
As a first thought I think you want to make a custom view controller navigation controller. Like UINavigationController, UITabBarController or UIPageViewController.
I'd also use a scroll view over a gesture recogniser maybe?
Either way it's gonna be a lot of work which means there are many many different ways to do it.
It sounds like you have a decent idea of how you want it to work. Give it a whirl and see what happens. I reckon you can have a decent bash at it.
If you get stuck let us know and we'll try to help :)
So, I have a setup where an UIPopoverController presents information at the cursor in a text view. When the cursor moves, I present it again. But this is jarring, and I'd like for the popover to move in a smooth, animated fashion. Will I really have to do that manually by using a series of presentFromRect calls, or is there a better way?
Unfortunately UIPopovers are not designed to be moved around like that.
The only way to do that without presenting it all over again is to write your own UIPopover replacement and animate its position using the standard CAAnimation or UIKit animation techniques.
If think you cannot do that without use presentFromRect. But if you really want to do this, create your own. Recreate the look of a popover controller using a UIView and track the touches. You can use an alternative like WEPopover.
I know what I want to do, but I'm stumped as to how to do it: I want to implement something like the iOS multitasking gestures. That is, I want to "steal" touches from any view inside my view hierarchy if the number of touches is greater than, say, two. Of course, the gestures are not meant to control multitasking, it's just the transparent touch-stealing I'm after.
Since this is a fairly complex app (which makes extensive use of viewController containment), I want this to be transparent to the views that it happens to (i. e. I want to be able to display arbitrary views and hierarchies, including UIScrollViews, MKMapViews, UIWebViews etc. without having to change their implementation to play nice with my gestures).
Just adding a gestureRecognizer to the common superview doesn't work, as subviews that are interaction enabled eat all the touches that fall on them.
Adding a visually transparent UI-enabled view as a sibling (but in front) of the main view hierarchy also doesn't work, since now this view eats all the touches. I've experimented with reimplementing touchesBegan: etc. in the touchView, but forwarding the touches to nextResponder doesn't work, because that'll be the common superview, in effect funnelling the touches right around the views that are supposed to be receiving them when the touchView gives them up.
I am sure I'm not the only one looking for a solution for this, and I'm sure there are smarter people than me that have this already figured out. I even suspect it might not actually be very hard, and just maybe my brain won't see the forest for the trees today. I'm thankful for any helpful answers anyway :)
I would suggest you to try using method swizzling, reimplementing the touchesbegan on UIView. I think that the best way is to store in a static shared variable the number of touches (so that each view can increment/decrement this value). It's just a very simple idea, take it with a grain of salt.
Hope this helps.
Ciao! :)
A possible, but potentially dangerous (if you aren't careful) approach is to subclass your application UIWindow and redefine the sendEvent: method.
As this method is called for each touch event received by the app, you can inspect it and then decide to call [super sendEvent:] (if the touch is not filtered), or don't call it (if the touch is filtered) or just defer its call if you are still recognizing the touch.
Another possibility is to play with the hitTest:withEvent: method but this would require your stealing view to be placed properly in the subview, and I think it doesn't fit well when you have many view controllers. I believe the previous solution is more general purpose.
Actually, adding a gesture recognizer on the common superview is the right way to do this. But it sound like you may need to set either delaysTouchesBegan or cancelsTouchesInView (or both) to ensure that the gesture recognizer handles everything before letting it through to the child views.