7

I think this is more of an SDK flaw than my apps' but recently I've been trying to use UIPasteboard to copy strings from my app and it works fine to pasting somewhere when I'm inside the app.

When I jump to another app by either pressing the home button or anything like that, I simply don't have the option to paste the copied content.

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[pasteboard setString: @"blah" ];
NSLog(@"%@", pasteboard.string);

It will print "blah" in this case, and whenever I quick touch a textfield, it will show the paste option. But if I go to Safari, Notes or Mail It doesn't show me that option.

Also, If I copy something from mail and go to my app, I won't see the paste option aswell...

4

5 に答える 5

4

アプリケーション間で永続的なペーストボードを行うには、使用する必要があります

UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:pasteboardIdentifier create:YES];
[pasteboard setPersistent:YES];
[pasteboard setString:string];
于 2012-11-23T15:18:54.723 に答える
2

同様の問題があります。これは、サードパーティのライブラリと競合する可能性があります。Flurry Analytics を削除すると、すべて問題ないことがわかりました。ライブラリは「EnterBackground」イベントで何かを行うと思います。

アプリケーションの「クリーンアップ」を試みることができます。AppDelgate の enterbackground デリゲートの関数呼び出しを削除します。

つまり、「DidEnterBackground」中にコードまたはサード パート コードが sth を実行して、クリップボードを大量に消費する可能性があります。これについては何もコーディングしないでください:

  • (void)applicationDidEnterBackground:(UIApplication *)アプリケーション{}

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions – で呼び出す必要があるサードパーティ コードも削除してみてください。

于 2011-12-09T07:38:16.380 に答える
1

Flurryは3.0.4をリリースすることでこの問題を解決したようです

残念ながら、ユーザーの苦情が私のメールボックスにあふれました...

于 2011-12-14T22:56:51.663 に答える
1

Flurry 2.8.4 に戻すことで、ペーストボード機能を復元することができました。Flurry 3.0.2 および 3.0.3 では、メモ帳などの外部アプリでのコピー/貼り付けのサポートが無効になっています。

于 2011-12-09T19:16:53.150 に答える
1

// テキストを保存

  UIPasteboard* board = [UIPasteboard
pasteboardWithName:@"com.company.wtv" create:YES]; 
board.persistent=YES; [board setValue:@"123456ccc"
forPasteboardType:@"com.company.wtv.sharedValue"];

// Retrive text

    UIPasteboard* board = [UIPasteboard pasteboardWithName:@"com.company.wtv" create:YES];
    board.persistent=YES;
    NSData* result=nil;
    NSString*resultStr=nil;
    result =[board valueForPasteboardType:@"com.company.wtv.sharedValue"];
    resultStr=[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding];// I got resultStr containing
123456ccc

    NSLog(@"key %@",resultStr);
于 2015-07-20T04:11:02.967 に答える