Advertise here

Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

UIPasteboard - Not working anymore with Xcode 4.5 on iOS 6

esotericesoteric Posts: 617Registered Users @ @ @
edited September 2012 in iOS SDK Development

In a few of my apps I have a feature to share images users have created by iMessage/MMS. Basically all this does when the user selects the option is
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.image = [UIImage imageNamed:@"Image user wants"]
Then it opens Apple's Messages app and they can paste it in a text/iMessage.

With one of my apps that was built/archived/sent to app store with Xcode 4.4.1 (before any iOS 6 changes), when I download the app on my 2 devices these are the results:
iPhone 4 with iOS 5.1.1 - Works as expected, image is pasted properly and user can send.
iPhone 4 with iOS 6.0 - Also works as expected.

Now here's the problem.
For another app which I did a few changes for iOS 6 and built/submitted using Xcode 4.5, the are the results i'm seeing when downloading the app from the App Store. (Keep in mind that I haven't touched any of the UIPasteboard code)
iPhone 4 with iOS 5.1.1 - Still works exactly as expected.
iPhone 4 with iOS 6.0 - When I try to paste the image into Messages it doesn't show up as an image. Instead it shows a little icon with the text "IMG ##.jpeg" (like the image in the link below). And when you try to send whatever that image is it fails..on iMessage or with MMS.
-The images are made as .PNG but I also tried creating them as .JPEG before sending and the problem persists.

Attached Image

I don't see any UIPasteboard iOS 6 changes so i'm not sure what's causing this.
Any help is appreciated!

Just opened my same projected that was submitted and broken on the app store with Xcode 4.4.1. Built the app on my iPhone 4 with iOS 6 and it works correctly again. So this seems to be a problem with Xcode 4.5.
Post edited by esoteric on


  • toblerpwntoblerpwn Posts: 3New Users
    Yo Esoteric-

    I'm running in to the same problem. Nice little HUGE issue that I BARELY caught before submitting.. =/

    Wouldn't re-building on an old version of Xcode prevent you from compiling with newer (read: iOS6) features? I'm not sure how to go about this - this is my first iOS update as a developer. And it's been a doozy. ;>
  • esotericesoteric Posts: 617Registered Users @ @ @
    Well I didn't really add any new iOS 6 specific features. Just updated some SDK's and a few other changes. So when I reopened it in Xcode 4.4.1 everything was still working.
    It's too bad this won't work if we want to use Xcode 4.5 and use iOS 6 features/full iPhone 5 screen.
  • toblerpwntoblerpwn Posts: 3New Users
    indeed indeed .. well thanks dude :)
  • esotericesoteric Posts: 617Registered Users @ @ @
    I seem to have found a way to make it work with Xcode 4.5 using the following code.
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];        
    NSData *imgData = UIImagePNGRepresentation(@"imageyouwant");
    [pasteboard setData:imgData forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];
    Not sure if this is the right way to do it but when compiling with Xcode 4.5 on my iOS 6 devices, it not works like it used too.

    Let me know if this works for you as well!
Sign In or Register to comment.