I am writing an app that has a simple form with a photo upload tool, the user uploads their photo to the form and it is displayed in an image view, i then want that image to be in the blank e-Mail that opens up upon clicking submit. I am using the following code to try and achieve this:
let messageBody = "\n\nPhoto: \(imageView.image!)"
The photo gets uploaded and shows in the image view fine but the email displays the following where the image is supposed to be " size {1334, 70} orientation 0 scale 1.000000"
Any help would be greatly appreciated!
Your code (or my previous answer) won't work because you are converting the image to a string (messageBody). And it basically shows you a string of information about the image. So your only option is to write the message in HTML (and set isHTML to true). The good news is that it isn't too hard.
I think the code below should work.
let messageBody = "<html><body>Photo:<img src=\"yourImage.png\"></body></html>"
Related
I have some code that will select an image from either the user's photo library or from their camera and display it in an image view. I'm accessing the photo URL from the following line of code:
let pickedPhotoURL: URL = (info["UIImagePickerControllerImageURL"] as? URL)!
This works perfectly when accessing a photo from the user's library. However, I'll always get a nil value at this line why trying to access the photo via the camera. Anyone have any ideas / suggestions?
It's because that value isn't set for a camera. Use UIImagePickerControllerOriginalImage (or edited image if you are using that).
That key gives you a UIImage -- if you need a URL, you need to save it somewhere.
Also, don't use strings, there are keys defined for you.
I'm using Firebase Database & Firebase Storage. I have an iOS Swift app, that allows the user to select multiple images, upload them to Firebase Storage, after the upload, it gets the downloaded URLs and stores them like:
In order to display those images in the app, I have the following xib file:
Where the middle (big) UIImageView is inside of a UIStackView because it could display more than 1 image.
My problem is that I get the URLs from the database, but for some reason I'm not able to display them in the app. I use the framework SDWebImage for caching and displaying images. So far in the app, it worked fine, but not here. I don't get where I'm wrong.
if let photoURLString = post?.photoURLs
{
for photo in photoURLString
{
let photoURL = URL(string: photo)
print(photoURL!)
postImage.sd_setImage(with: photoURL)
//postImagesStackView.addArrangedSubview(postImage)
}
}
post is the model object. I'm using for in to loop through the array of images from the database. When I print each url, I get the actual URL. But it's simple not displayed. I get this. The images are nowhere to be found/displayed:
Try to add aspect ratio for UIImage. Ex: In xib file, set ratio of UIImage to 1.
Since iOS8, the behaviour of Mail with the pasteboard seems to have changed.
I am trying to copy both images and text from my app, in a format that I can paste into the Mail app.
A UIPasteboard containing both images and text will only paste the images into Mail. A pasteboard containing one or the other works fine.
I create a dictionary for each text and image element, add them all to an array, then set pasteboard.items to the array. This method has worked for a year or two.
My guess would be that Mail now takes the "best" data in the pasteboard, and assumes that the text was included only as a fallback (such as a text description).
Has anyone else observed the same problem, and is there a workaround?
When I tried to add some text and a image to the UIPasteboard a few days ago, I found that ONLY the image was added to the UIPasteboard.
UIPasteboard.generalPasteboard().string = text
UIPasteboard.generalPasteboard().image = image
I use the code above then check UIPasteboard.generalPasteboard().string was nil, I firmly sure that my text wasn't nil. So, this may be a bug.
I use twitter API fetchTimelineForUser:(NSString *)username to fetch tweets timeline. The size of user profile image in this object is normal. But I need a bigger size image.
How can I accomplish this?
BTW, I don't want to fetch the user object from twitter.
Thanks.
In profile image url you are getting _normal, appended with the image name like http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png
To get actual image remove _normal. It will be http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3.png
You can see profile_image_url and profile_image_url_https in user object, normal sized image is mostly 48px - 48px. By modifying the url you can get larger image.
For more info please see this link.
Hope this helps.. :)
Im trying to make an app for planning out where you want to put "shelves" on a wall (sounds strange i know ;) )
i have got it so the image is picked from the UIImagePickerController then loaded in a new ViewController i also have a button at the bottom of the ViewController that i want to open a list of images to select from that once selected the user can move around then stretch the required size if they don't like, delete and once they are happy i want my second button to save the image and put it into an email ready for sending.
I have looked at a few ways but none of them seem to be "adequate" would be so grateful anyone could suggest any ways or even help me with some code, I'm very new to this and this is my first app.
Im not too sure on the code you'd need to see as none of what is written yet is relevant to this part of the app
This is a 2 part so the first is, what way do i go about it?, the second is what code?
Thanks
-(UIImage *)GetStreachableImage
{
UIImage *takephotoButtonImagenormal = [UIImage imageNamed:CHOOSE_TAKE_NORMAL_IMAGE];
UIImage *strechableButtonImageNormal1 = [takephotoButtonImagenormal stretchableImageWithLeftCapWidth:takephotoButtonImagenormal.size.width/2 topCapHeight:takephotoButtonImagenormal.size.height/2];
takephotoButtonImagenormal=nil;
return strechableButtonImageNormal1;
}
try this