Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ----- simplest: -----
- - (void) application:(id) app didFinishLaunchingWithOptions:(NSDictionary*) opts;
- {
- ...
- services = [ILServicesController new];
- services.showsServicesActionInMenu = YES;
- // with this, all menus will show a Services… command at the end.
- // you can easily tap into this by implementing a UIResponder action in your view or view controller subclass, and let SwapKit's default impl manage everything for you. Just show the menu as you would for cut/copy/paste.
- // SK2 contains default implementations of this for UIKit text controls, so they work without writing any extra code!
- ...
- }
- // ----- more control: -----
- - (void) sendSomeImageToSwapKit {
- ILServiceIntent* intent = [ILServiceIntent intentForSendingImage:self.selectedImage action:kILServiceActionAny];
- [services invokeServiceForIntent:intent fromViewController:self.window.rootViewController];
- }
- // ----- even more control: -----
- - (void) sendSomeTextToSwapKit {
- ILServiceIntent* intent = [ILServiceIntent intentForSendingSubstringOfEditedText:self.textField.text selectedRange:self.textField.selectedRange action:kILServiceActionAny];
- // The above would allow SwapKit to show service entries for "selection", "paragraph", "entire document" etc in the picker automatically.
- ILServiceInvocationController* invo = [services controllerForInvokingServiceForIntent:intent];
- invo.delegate = self;
- [invo proceed];
- }
- - (ILServiceInvocationPresentationStyle) presentationStyleForInvocationController:(id) ctl;
- {
- return kILServiceInvocationPresentationModal; // on iPad, causes any view controller shown to be displayed as a modal view controller instead of a popover
- }
- - (void) presentModalViewController:(id) vc forInvocationController:(id) ctl;
- {
- vc.modalPresentationStyle = // blah, customize customize
- [self.window.rootViewController presentModalViewController:vc animated:YES];
- }
- - (void) dismissModalViewController:(id) vc forInvocationController:(id) ctl;
- {
- [vc dismissModalViewControllerAnimated:YES];
- }
Add Comment
Please, Sign In to add comment