How to create a custom pop-up modal dialog on iOS? - ios

I am new to iOS development. I could see Apple's guide about Modality.
However, I don't know how to implement a custom modal dialog that looks similar to how Gmail app's:
How should I get started? Are there sample codes anywhere for self-learners to follow along?
Thanks a lot

You should investigate UIViewControllerTransitioningDelegate examples.
This will allow you to define a custom transition that you could reuse across a number of different view controllers. It also allows you to decouple transition logic from where the modal is being presented or what is being presented.

Related

iOS NavigationController - Best Practice

I'm new to iOS programming and was wondering, should you only use a navigation controller if your entire app will be embedded in it? I've embedded view controllers for login/signup screens and was wondering for the actual game play controllers, is it bad practice to navigate to an entirely new view controller? Or should I push to another screen in the navigation controller to start a new game etc...
Any advice will be greatly appreciated. Thank you.
I think that the best practice to use UINavigationController is to use them whenever you want to able the user to go back, and/or if you want to add bar buttons to it (For example to add new items, to perform a search, to open settings, and so on).
You can even work with several navigation controllers in the same application according to your needs. You want to understand first the flow that your application will have.

UIAlertController as Child View Controller

In order to allow for better customization in my app, I want to put UIAlertController within a UIViewController subclass. The alert should be a child of the UIViewController to allow for more flexibility.
What is the best way to achieve this?
I have tried so far to add the alert as a child view controller. When I want the alert to show up, I present the container view controller modally.
I have also tried to call presentViewController on the view controller (with the alert as a parameter). However, I'm not sure what the correct approach is to achieve what I am looking for.
Edit: Neither of these solutions were working as I had hoped, but I don't know if that is because I did something wrong or because the approach is wrong.
Edit 2: The added functionality is providing UIKeyCommands to make selection of the alert options easier. I am not subclassing UIAlertController for two reasons: (1) the documentation states that it should not be subclassed, and (2) adding key commands UIAlertController doesn't work.
Could you please explain what sort of flexibility such an approach provides? I'm not doubting that it does, as I'm relatively new to iOS development, but I can't quite figure out what you're trying to achieve using a child view controller.
If you simply want to present a UIAlertController from your view controller, just create the alert controller, configure it, and use presentViewController to display it.
As a general approach, however, I follow the advice found in the top answer in this thread. It suggests using either a UIAlertController subclass or category with a custom show method that provides the alert controller with its own window so that alerts can be presented 'globally' so to speak.
I don't think your question is absolutely clear, but maybe you want a custom pop-up view controller, not alert? Then you probably need something like STPopupController - it's customisable and easy to use.

How to achive facebook kind of SSO in iOS sdk? (The way the opens a view for login and loading )

How to achive facebook kind of SSO in iphone sdk?
(The way they open a view for login and loading).
I Don't want to use UIViewController and want to show Login/Loading view
and want to put Login/Loading code at one place
as that view is going to be opened from lots of controllers.
Is there any way to achieve this? (protocol?)
Not sure if this is what you mean, but the following tutorial shows a handy mechanism for allowing you to design a popup overlay window using a UIViewController.
http://blog.typpz.com/2013/12/09/ios-sdk-create-a-pop-up-window/
You design a UIViewController in storyboard which contains your overlay popup view. The surroundings remain transparent. You can create an instance of this UIViewController in your code and then ask it to overlay its view onto your existing controller view. The result is a popup window similar to a UIAlertView, into which you can put whatever you wish.
I use this for doing popup help overlays, but I image you could easily use it for your facebook like content.
Benefit 1) Since you design it in a UIViewController, you can use all the size class related layout and you can see how it will look on all the different device types.
Benefit 2) It is totally reusable. From any controller, create an overlay UIViewController instance and ask it to overlay its content on your current controller. Reverse is to ask it to remove the overlay.

How to present popover with animations?

Currently, I'm using presentPopoverFromRect:inView:permittedArrowDirections:animated: to present my popover. But I'm looking for more fanciful animations (eg. the popover expanding from a particular point) to present the popover.
I've tried searching with keywords ios present popover animation but can't find any useful results. Not sure if I'm using the wrong keywords or it is impossible to present popovers with animations.
When using a UIPopover, there is currently no easy way to present it with a different animation than the one that iOS provides. It would definitely be possible to do a custom animation to present a view, but it would be a very significant amount of extra work as you would have to do everything yourself. Two things you could look at if you really, really need to:
UIView animation. Links: Ray Wenderlich tutorial, Apple documentation (search the page for "animation").
Core Animation custom transitions.
As of iOS 7.0 it is possible to present any view controller so that it does not completely obscure the previous view controller, making it possible to create "fake" popovers. Using the UIViewControllerTransitioningDelegate protocol you can then create any animation you would like.
Here is a good example of how to create a fake popover with a custom animation.

is it necessary to Delegate UITabBarController to AppDelegate

I am a newbie summoned with lot of Questions. I am working with UITabBarController Window base application. Is it necessary to Delegate UITabBarController to AppDelegate. Its working fine for me with both delegating and not delegating.
i got some idea of delegate while working with UITableViewController. Please let me know what will happen with and without delgating UITabBarController.
Please suggest any Material or PDF or Book where i can get good idea with AppDelegate other than Apple docs.
You should read about the Model-View-Controller (MVC) paradigm and how delegates fit into it. A good source would be Apple's document on the matter, as well as most beginning iPhone Development Books. I would suggest this one, and a good starting place for MVC is here.
To answer your specific question, you want your AppDelegate to implement the UITabBarControllerDelegate protocol " when you want to augment the behavior of a tab bar. In particular, you can use it to determine whether specific tabs should be selected, to perform actions after a tab is selected, or to perform actions before or after the user customizes the order of the tabs. After implementing these methods in your custom object, you should then assign that object to the delegate property of the corresponding UITabBarController object." (From Apple's Class Document here.
In simplified terms, you use it when you want to do something custom/specific when a viewController is selected from the tab bar (– tabBarController:didSelectViewController:)or will be (– tabBarController:shouldSelectViewController:). It can also be used to help with customizing the viewControllers showing on the tab bar if you have a need for more than allowed to be displayed at once (using a "More..." or whatever tab).

Resources