iOS:UIPasteboard setImage:在iOS6和/或Xcode 4.5上失败 [英] iOS: UIPasteboard setImage: fails on iOS6 and/or Xcode 4.5

查看:270
本文介绍了iOS:UIPasteboard setImage:在iOS6和/或Xcode 4.5上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:在Apple网站上添加了错误12408800.

Update: Added bug 12408800 on Apple's site.

我正在复制一个或多次UIImage到UIPasteboard,它一直在工作,直到我的手机升级到iOS 6。

I am copying some one or multiple UIImage to the UIPasteboard, and it's been working like gangbusters.. until my phone upgraded to iOS 6.


  • Xcode 4.5 with iOS 5.1 - 确定

  • Xcode 4.4 with iOS 6.0 - 也行OK 根据这篇文章

  • Xcode 4.5 with iOS 6.0 - FAIL

  • Xcode 4.5 with iOS 5.1 - OK
  • Xcode 4.4 with iOS 6.0 - Also OK (according to this post)
  • Xcode 4.5 with iOS 6.0 - FAIL

(还测试了通过TestFlight分发,它的价值 - 仍然失败)

(also tested distributing via TestFlight, for what it's worth - still fails)

这是我的代码(超级基本等):

Here's my code (super basic, etc):

// add image to clipboard
UIImage *image = [[UIImage imageNamed:@"testimage"];
[[UIPasteboard generalPasteboard] setPersistent:YES];
[[UIPasteboard generalPasteboard] setImage:image];

以下是当我尝试粘贴MMS / iMessage窗口时会发生的情况(对不起巨大的屏幕截图) ;视网膜显示..):

And here is what happens when I try to paste in an MMS/iMessage window (sorry for huge screenshot; retina display..):

..以及iOS6模拟器中的Messages示例应用程序失败的示例(请参阅两个问号..?):

..and an example of a failure on the Messages sample app in the iOS6 simulator (see the two question marks..?):

就像我说的,上面的代码已经工作了很长时间,所以我确定这是新的东西。

Like I said, the above code has been working for ages, so I'm sure this is something new.

有什么想法吗?在链接的帖子中,作者建议重新编译旧版本的Xcode - 但这不会导致其他iOS6库停止工作吗?

Any thoughts? On the linked post, the author suggests re-compiling on an old version of Xcode - but wouldn't that cause other iOS6 libraries to stop working?

推荐答案

这适用于我的iOS 6设备的Xcode 4.5。

This works for me on Xcode 4.5 for my iOS 6 devices.

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];        
NSData *imgData = UIImagePNGRepresentation(@"image");
[pasteboard setData:imgData forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];

这篇关于iOS:UIPasteboard setImage:在iOS6和/或Xcode 4.5上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆