Reputation: 1619
I create and present UIActivityViewController
in my app with custom UIActivity
items in it.
When I tap UIActivity
icon, UIActivityViewController
slides down and my modal view controller is presented. However, when I dismiss my VC, UIActivityViewController
shows up.
How can I make it disappear and never shows up again when activity item is pressed?
Upvotes: 3
Views: 7437
Reputation: 197
i found this by Ethan Huang
[self presentViewController: activityController animated: YES completion:nil];
activityController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popPC = activityController.popoverPresentationController;
popPC.barButtonItem = saveBtn;
popPC.permittedArrowDirections = UIPopoverArrowDirectionAny;
read all about it here :
http://getnotebox.com/developer/uiactivityviewcontroller-ios-8/
Upvotes: 0
Reputation: 55
Let's say when Activity A is chosen from UIActivityVC, you want to present modal view controller M on your current view Controller C .
If you implement A's -(UIViewController*)activityViewController
method, you need to call [A activityDidFinish]
in your modal view controller M's dismiss method;
If you implement A's -(void) performActivity
method, it's impossible to present modal view , because current view controller C is in the process of dismissing UIActivityVC
.
I think the final solution is a bit tricky. My basic idea is to subclass UIActivityViewController
and override -(void) viewDidDisappear
method. Thus you can do whatever you like( i.e present your own modal view,or push a sequence of other view controllers) on your current view controller C.
Upvotes: 2
Reputation: 318874
You need to call the activityDidFinish:
method on the chosen UIActivity
.
From the docs for UIActivity activityDidFinish:
:
Discussion
This method dismisses the sharing interface provided by theUIActivityViewController
object. If you provided a view controller using theactivityViewController
method, this method dismisses that view controller too.You must call this method after completing the work associated with this object’s service. This is true regardless of whether you used the
activityViewController
orperformActivity
method to initiate the service. When calling the method, use the Boolean value to indicate whether the service completed successfully.
Upvotes: 2