How to provide 3D Touch quick actions inside iOS app - ios

If you were using Home app in iOS, you may have noticed that there's Quick Actions-like menu when you force touch on accessory. If device doesn't support 3D touch, then you do it with the long press. Here's two videos, first from iPhone 5, that doesn't support 3D Touch, and the second from iPhone 7 that does, https://imgur.com/a/jdQXPg7, https://imgur.com/a/W4cVnNI
How to realize such functionality? What class can be used as a view for this? Should I write custom UIView subclass? There are a few similar questions, but they do not provide specific answer.
EDIT:
I do not mean how to create quick actions, I mean how to create actions view when I force touch UICollectonViewCell.
Any help wold be appreciated.

Related

iOS - Is there a programmatically way to create multiple windows that don't split the screen?

I'm using UIScenes and SwiftUI to create a simple app.
I need to create multiple windows programmatically, but not with the same design outcome from requestSceneSessionActivation, that splits the screen into 2 pieces. I need the other one, like the image...
I didn't find anything in the UIScene documentation for it.
If you know a way to close it too, it would be awesome!
Unfortunately UISceneActivationRequestOptions (passed to requestSceneSessionActivation) doesn't provide an option to specify how the new scene should be presented. Oddly there is a UIWindowSceneDestructionRequestOptions class for indicating how a scene can be dismissed. There should be a UIWindowSceneActivationRequestOptions class that allows you specify how it is shown. I suggest filing an enhancement request with Apple using the Feedback app on iOS 13.
Closing a scene can be done using UIApplication requestSceneSessionDestruction.

Swift: implementing a new item dialogue like 'add alarm' in clock app

I want to implement an add new item dialogue in my app similar to add alarm dialogue in the clock app (screenshot). Prior to this moment I always used the same storyboard scene design for iphone and ipad with autolayout to make it look good on both devices. But I'm wondering how can I implement a view similar to Add Alarm dialogue - it looks very compact on both iphone and ipad especially because on ipad it's a separate small view that is not stretched across the screen. Can somebody please point me how to implement it? I don't really need the code, just some directions that can help me.
Found it in the apple documentation:
https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html

With iPhone 7 and UIFeedbackGenerator, which system actions perform which kinds of taptic feedback?

(This question is mostly applicable to those of us developing iPhone apps without access to an iPhone 7.)
I want to incorporate the new taptic feedback available with the iPhone 7 into my apps, and I want to make sure my uses of it align properly with how iOS uses them at a system level. Without a device I can't test this.
Apple provides a document describing the different kinds of feedback: https://developer.apple.com/ios/human-interface-guidelines/interaction/feedback/ Namely "Notification", "Impact", or "Selection".
For instance, in Mail.app, when you slide a cell to archive it, it gives taptic feedback. Which of those three above (and their corresponding "variation") does Mail.app use? I'm guessing "Selection" but may be wrong.
Bonus points for pulling down Notification Center or Control Center, as well as any others you can provide for reference, but the gestures in Mail.app would be an awesome start.
You should check out this article, it gives you an overview how UIFeedbackGenerator works. https://www.hackingwithswift.com/example-code/uikit/how-to-generate-haptic-feedback-with-uifeedbackgenerator
Alternatively, you can create a demo project and check out which feedback is best suited for your needs.
Edit:
It's the selection feedback for Mail app. The notification center uses multiple feedbacks depending upon the sliding. If you do it slowly, it's impact heavy and how if you do it a bit slowly, it's impact light and if you just slide it down immediately, it produces no feedback.

How to create a popup window in Xcode Swift?

I have an iOS info app. The main screen of the app consists of rows of icons. I want that after tap on certain icon card with information appears and background blurs. To close the card I need to swipe up or down. It is very similar to Instagram's imageviewer.
Please help me create that.
P.S. This is my first project so please keep this in mind when you going to describe the method.
It should look like this
The answer to your question is probably hidden beneath the layers of how you can segue between the scenes of a storyboard. First, you create a scene like this in the storyboard and use some third party libraries to present it as a 'pop-up'. It is not possible for you to do that natively as Apple has not added any segue style showing the scene like a pop-up on the iPhone screens (On iPad it's possible - check how Apple presents choose Wi-fi network in Settings). For that purpose, you can use BlurryModalSegue or CNPPopupController to perform such operations.
Thank You!

iOS: Facebook chat heads behaviour and animations

This question is probably a little out of date, but I've been using the new Facebook for iOS with the "chat heads" feature (with the chat heads only present within the app), and was wondering how Facebook went about implementing this? E.g. How did they handle the drag animations for the chat heads, and also (when clicking on the chat head) how did they manage to overlay a UITableView on top of the "base" UIViews in the background?
Is this all part of UIKit, or did they create their own classes to handle this?
To answer #StuartM's question in the comments, in the last couple of months I've had a bit more experience with UIKit, and I think I have a rough idea on how I would implement something like this if I was going to do it.
What I would do is for the chat head, create a styled UIButton and add it as subview to the main Window. For the dragging, I would add a Gesture Recognizer to the UIButton to respond to the drags, and for the "snapping to edges" I would use iOS 7's new UIKit Dynamics (http://www.raywenderlich.com/50197/uikit-dynamics-tutorial).
As for showing the UITableView overlay with the chat history, I would use a Child View Controller (https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html#//apple_ref/doc/uid/TP40007457-CH18-SW6) and as for the popping open animation, I would just use the default UIView animations, maybe using animation transactions as I'm not sure I can do everything with just the implicit animations?
And I think that should be it. To be honest, I think anyone who has a handle on those frameworks should be able to build anything in their iOS apps, and if you were to create a "chat heads" like sample project in your spare time, should give you a pretty indepth knowledge of how those frameworks work.

Resources