在后台运行时像Pastebot一样抓住UIPasteboard
|
我知道这是可能的,因为Tapbots Pastebot可以做到这一点。我试图在iPhone应用程序在后台运行时抓取UIPasteboard,然后像Pastebot一样将其添加到UITableView中,但是我也试图缩短链接(如果它是URL)并将其复制回UIPastboard,以便准备就绪供用户粘贴到任何地方。现在,Pastebot显然通过播放音频文件10分钟而在后台运行。我已经在applicationDidFinishLaunching中设置了NSNotificationCenter
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pasteboardChangedNotification:) name:UIPasteboardChangedNotification object:[UIPasteboard generalPasteboard]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pasteboardChangedNotification:) name:UIPasteboardRemovedNotification object:[UIPasteboard generalPasteboard]];
- (void)pasteboardChangedNotification:(NSNotification*)notification {
pasteboardChangeCount_ = [UIPasteboard generalPasteboard].changeCount;
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if (pasteboardChangeCount_ != [UIPasteboard generalPasteboard].changeCount) {
[[NSNotificationCenter defaultCenter] postNotificationName:UIPasteboardChangedNotification object:[UIPasteboard generalPasteboard]];
}
}
谁能指出我的方向,以便抓住UIPasteboard并缩短链接(如果它是URL,然后将其发送回UIPasteboard)?我已经阅读了多任务开发文档和UIPasteboard文档。如果有人有解决方案,可以与我分享吗?
谢谢
没有找到相关结果
已邀请:
3 个回复
葛瞎说漓
,而只是在后台定期复制
的内容。 下面的代码每秒检查一次“ 2”,持续一千秒钟。我相信一个应用程序可以在后台运行大约10分钟而无需播放音频。如果您在后台播放音频文件,则应用程序可以继续运行。
芯伶句餐绕
傻寺俊擒