Is there an iOS equivalent of NSRunAlertPanel? - ios

I am trying to, when a button is pressed, a small menu comes up, like NSRunAlertPanel in Cocoa. It is like in iOS, when you press reset, it gives you options to continue, or go back. Image:
How do I do this?

As noted above, the answer to this is UIActionSheet in iOS < 8 and UIAlertController for iOS >= 8. Easier to grab a library that's abstracted that away for you; these look good.
Objective-C: MSAlertController for iOS
Swift: SimpleAlert for iOS

Related

Larger search bar in iOS 11? How to opt-into new style?

I noticed that in the App Store app, the UISearchBar they're using is larger. (see attached) — Currently when I compile for iOS 11b9 using Xcode 9b6, it still uses the old style, which is too small and is clipped by the status bar.
Is there some clean way to enable/mimic this larger variant of UISearchBar, while still maintaining backwards compatibility with older iOS versions?
I did find after the iPhone X announcement (and subsequent video additions to the Developer site) that there is a bit of a workaround necessarily: https://developer.apple.com/videos/play/fall2017/201
For iOS 11+ only:
Apply the UISearchController to the "navigationItem" not the UIViewController itself. Then set it to be "active" (= true).
Ensure this hidesNavigationBarDuringPresentation is true.
Monitor the delegate callback to track when it was dismissed, and then remove it from the "navigationItem" until it's needed again.
... Honestly it seems like this was a bit of an afterthought, but it does work and is good enough for now.

Swift 3 iOS 10 - Apply the "Slide to Unlock" animation to a label

I want to use the "slide to unlock" animation from iOS for a button. I just want the animation not the function behind it.
To be honest I have no idea how to start. I googled this a while, but I found nothing for Swift 3.
Here is what I want in my app
Try out Shimmer from Facebook. They use it for loading but its usable on labels. Looks very similar to the iOS “Slide to Unlock”.
Shimmer

How to implement the behavior of image tapping like what the Notes app does in iOS 9.x?

I am practicing a notes app, in which I use NSAttributedString to store the words and photo inputted in this app.
Now I am trying to implement the image tapping behavior like what the Notes app does in iOS 9.x, in which if the added photo is tapped, the screen turns to another mode, like the screenshots below.
screenshots of the Notes App in iOS 9.x
After searching Google and Stackoverflow, I found the textView:shouldInteractWithTextAttachment:inRange: method of NSAttributedString may be used to catch the tapping image behavior. However, this results in the words and photo not editable because it is necessary to make self.myTextField.editable = NO in order to enable the method above. Maybe it is possible to make a button to switch betweenself.myTextField.editable = NO and self.myTextField.editable = YES, but I'm still hope to implement what the notes app (in which there is no such a switch button) does in iOS 9.x.

How to show a popup(see image) in iOS

Just starting out with iOS developing in Swift so I'm not certain how to call this thing.
What I'm trying to accomplish is a choice like the image below.
What is it called and where do I start?
UIActionSheet is what you are searching for.
Be careful because it's deprecated since iOS 8 but the reference links to the replacement as well.
in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet.

UIActionSheet on iOS8

I have an app that connects to Chromecast - I referenced from the Chromecast Sample Code which uses UIActionSheet to display the list of Chromecast devices I can connect to.
This was working well for my app which has been running with BaseSDK=iOS6.1. Recently I tried to upgrade to BaseSDK=iOS8.1 and the UIActionSheet doesn't show anymore.
I understand that it has been deprecated in iOS8, but does that mean it wont work anymore? I thought deprecated methods typically take some time to "phase out".
So my main questions are:-
Can I still use only UIActionSheet? Is it just a matter of view hierarchies being changed which is why my ActionSheet is not showing anymore?
If the answer to question 1 is NO, what can I do to allow compatibility with both iOS7 and iOS8.
With iOS8.1 sdk UIActionSheet is deprecated, you should do runtime check to see if it is available and act accordingly using correct class:
if objc_getClass("UIAlertController") != nil {
// UIAlertController is available use it with style UIAlertControllerStyleActionSheet
} else {
// no UIAlertController use regular old action sheet
}
For iOS8 and you above, you will have to migrate to the UIAlertController for both the action sheet and alert pop up.
In all honesty, I find the new API easier to work with. There is a little more here (in Swift, but not any harder in Objective C).

Resources