iOS Copy and Paste

2019-05-26 03:49发布

I'm creating an app to save my copied items anytime I copy something on my iOS device.

Is there anyway I can create an event so that anytime I copy something from any app on my iOS device it saves it into my app?

I want it to fire anytime I copy text so that it pastes it to my apps textbox.

3条回答
劳资没心,怎么记你
2楼-- · 2019-05-26 04:40
    UIPasteboard *pb = [UIPasteboard generalPasteboard];
    NSDictionary *CellData = [NSDictionary dictionaryWithDictionary:[ArrayName objectAtIndex:SelectedIndexPath.row]];
    NSString* strText = [(NSDictionary*)[(NSString*)[CellData objectForKey:@"Key"] JSONValue] objectForKey:@"english"];
    [pb setString:strText];
查看更多
一夜七次
3楼-- · 2019-05-26 04:51

Take a look at the UIResponderStandardEditActions informal protocol:

https://developer.apple.com/library/ios/documentation/uikit/reference/UIResponderStandardEditActions_Protocol/UIResponderStandardEditActions.html

The key is to ensure that your view controller can become first responder and then implement the following methods:

- (void)copy:(id)sender;
- (void)paste:(id)sender;
查看更多
在下西门庆
4楼-- · 2019-05-26 04:52
- (void)copy {

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = @"String";
}


- (void)paste {

        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];  
        NSString *string = pasteboard.string; 
        NSLog(@"%@",string");
}

Refer this Link UIPasteBoard

查看更多
登录 后发表回答