Use storyboard in share extension - ios

The extension Share when we created it, is automatically created one file called mainInterface.storyboard, which in this case seems to be a kind of custom screen for the share Extension.
In my case I changed this screen and to my surprise when I select my application to give share, it besides pulling the custom screen, it also commonly pulls the original screen on the share (that with the text field two buttons).
How can I make to no push original screen, but push the custom screen?

Most likely your view controller is still a subclass of SLComposeServiceViewController. That class will always display the default share UI if you use it. If you don't want that UI, you should change your view controller to inherit from UIViewController instead.

Related

Swift Input and event handling for storyboards

I've been trying to outline the basic functionality of a swift application I was developing. I created a basic gui with the storyboard functionality that xcode provides. Here is a picture of what it looks like currently:
What I want to do next is code up a way to receive and store input from the text fields I outlined in the storyboard. Additionally I want to receive information regarding certain settings that are placed from the switches I outlined in the second screen.
I've been looking through the files that xcode provides me but I haven't been able to find the one that contains the functionality for the storyboards. If someone could point me in the right direction for that i would greatly appreciate it. Ultimately I just want to be able to manage the input provided by the interface I outlined below. Thanks!
For each view controller on the storyboard make a subclasses of UIViewController.
In the inspector panel on the left of the storyboard set the class of each view controller to their respective subclass of UIViewController.
Open up the .swift file for that view controller and storyboard and ctrl + drag from the textField to the class this will cause a small popup where you can create an IBOutlet or IBAction.

Create a picker view to use on multiple ViewControllers

My app has multiple screens all of which are different and not related however i must have a burger button which opens the same drop down menu on each screen.
Is it possible in iOS to create the menu once as a view and reuse it on each screen or do I have to create it on each ViewController and implement it.
Any explanation as to how to achieve this would be great.
The best thing would be to implement a custom view or custom control which you reuse in every Controller you want. The good thing is with the new storyboard and a xib file you can even see it in realtime in the storyboard (#ibdesignable).
Check out this: Creating a Custom View That Renders in Interface Builder (Apple Documentation)
Or a great tutorial: Custom UI components

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.

Creating a reusable control which can be embedded in UIViews and handle its own modals

There's a particular control which I'm trying to build properly. I refer to it as an ImageTile. It's basically a little square box, which, when the user taps it, will present the user (via an action sheet in a popover) the option of selecting an image from the library, or taking a photo. Depending on the response, I then either present the UIImagePickerController inside a popover (for selecting an image) or modally (for taking a new picture). Once they take/select the image, I have a modal view which appears and allows them to edit the picture in a few simple ways. When they finish editing, the modal dismisses, and the original ImageTile, rather than being a blank square box, gets filled up with the user's edited image.
The issue is that this ImageTile control is going to be used profusely throughout several different parts of the application, across numerous View Controller hierarchies, and so on... and I really want it to be a basically totally self-contained unit, such that whenever I stick an ImageTile inside a UIView onscreen, all the above functionality is handled by the ImageTile itself.
Initially, I made it a UIViewController subclass (so it could present modals etc), and just added its view as a subview of a "holder" view onscreen. I know this isn't recommended, as the controller isn't part of the VC hierarchy then... and also, I wound up with some really weird behavior regarding things like autorotation, especially when the camera was involved.
What's the "right" way to implement something like this?
I think what you've done by making it a UIViewController subclass is correct. You should just use the methods that UIViewController exposes for adding child view controllers, such as - addChildViewController:.
You will also note that Interface Builder has a Container View object designed specifically for holding a place in the hierarchy for a child View Controller:

IBOutlets/actions and custom subview

Apologies if this seems a straightforward question! I'm using AVFoundation to build a custom camera app that allows the user to draw on the image after it's taken (similar to snapchat).
I have the camera functionality working. Currently, after the shutter button is pressed I add (as a subview) a standard UIImageView to display the photo taken. Seeing as I want there to be custom options at this stage (including drawing on the image), I proceeded to create my own subclass of UIImageView. I am designing this view in Interface Builder (xib file).
Say for instance I have a button on this custom view, that when pressed, simply deletes the image and takes me back to the camera view to take another image. Can I handle the IBActions for this custom view within the ViewController for my camera view? Is this bad practice?
Any guidance on how best to implement this would be really appreciated! Thanks.
I would not suggest putting the button on your custom view.
I would have the UIViewController display the custom view and also give display a button for your action. Most likely the UIViewController will want to display a UIToolBar at the bottom of the screen which will allow for multiple buttons/actions, but that's up to you.
But why do I say this? Compartmentalization. Your custom view has no need or use for the button. It's meaningless to what your doing... displaying the image. Your custom view will also probably be used in many locations, several of which won't want this button displayed. Even if your custom view had the button it wouldn't know what to do if someone tapped it. It would then have to pass that interaction off the view controller which cares about the action and and handle it. Your custom view will mostly likely have public methods allowing other code to give it directions (like clear or undo).
Depending on the say things go, you may decide you want a custom UIViewController which handles interactions on your custom view. Then any other view controllers could just add it in as a containerized view controller and you could have the same functionality with no code duplication at several places in your applications.

Resources