Guest User

Untitled

a guest
Jan 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1.  
  2. // ----- simplest: -----
  3.  
  4. - (void) application:(id) app didFinishLaunchingWithOptions:(NSDictionary*) opts;
  5. {
  6. ...
  7. services = [ILServicesController new];
  8. services.showsServicesActionInMenu = YES;
  9. // with this, all menus will show a Services… command at the end.
  10. // 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.
  11. // SK2 contains default implementations of this for UIKit text controls, so they work without writing any extra code!
  12. ...
  13. }
  14.  
  15. // ----- more control: -----
  16.  
  17. - (void) sendSomeImageToSwapKit {
  18.  
  19. ILServiceIntent* intent = [ILServiceIntent intentForSendingImage:self.selectedImage action:kILServiceActionAny];
  20.  
  21. [services invokeServiceForIntent:intent fromViewController:self.window.rootViewController];
  22. }
  23.  
  24. // ----- even more control: -----
  25.  
  26. - (void) sendSomeTextToSwapKit {
  27.  
  28. ILServiceIntent* intent = [ILServiceIntent intentForSendingSubstringOfEditedText:self.textField.text selectedRange:self.textField.selectedRange action:kILServiceActionAny];
  29.  
  30. // The above would allow SwapKit to show service entries for "selection", "paragraph", "entire document" etc in the picker automatically.
  31.  
  32. ILServiceInvocationController* invo = [services controllerForInvokingServiceForIntent:intent];
  33. invo.delegate = self;
  34. [invo proceed];
  35. }
  36.  
  37. - (ILServiceInvocationPresentationStyle) presentationStyleForInvocationController:(id) ctl;
  38. {
  39. return kILServiceInvocationPresentationModal; // on iPad, causes any view controller shown to be displayed as a modal view controller instead of a popover
  40. }
  41.  
  42. - (void) presentModalViewController:(id) vc forInvocationController:(id) ctl;
  43. {
  44. vc.modalPresentationStyle = // blah, customize customize
  45. [self.window.rootViewController presentModalViewController:vc animated:YES];
  46. }
  47.  
  48. - (void) dismissModalViewController:(id) vc forInvocationController:(id) ctl;
  49. {
  50. [vc dismissModalViewControllerAnimated:YES];
  51. }
Add Comment
Please, Sign In to add comment