Unable to show contact image in shortcut items - ios

We develop an app with some features in iPhone 6s.
I faced some issue when showing the contact image in the shortcut item. I am able to show the dummy image, but I am unable to dynamically fetch the contact image and show in the shortcut items.
My images are in documents directory. I need to show in shortcut item.
UIApplicationShortcutIcon iconWithTemplateImageName: --------]
I tried this:
UIApplicationShortcutIcon * photoIcon = [UIApplicationShortcutIcon iconWithTemplateImageName:SaveImage.png];
I can show a direct local image, but I cannot show the image from addressbook.
Any recommendations are welcome.

This question is confusing. You say your images are "in the documents directory", but you want to display images from the address book.
What I recommend doing is getting the contact you want from the CNContactStore (a CNContact has an image attribute named imageData) and then pass it to UIApplicationShortcutIcon which has an init method that takes a CNContact as a parameter (which means it would actually use that image).

Related

How to access all the albums and then by clicking the album all the photos should open

I want to show the image selecting option like whatsapp , first fetch list of all the album and then by clicking on that album all the photo should come and being able to keep track of all photo selected by user . i.e Multiple photo selection.enter image description here
I have attached the image to show the requirement.
Please help me.
Thanks in advance
You have to use asset library for it,
Here are some libraries you could use:
1. LimPicker (Similar to WhatsApp's image picker)
2. Fusuma(Instagram like image selector)
3. YangMingShan(Yahoo like image selector)

Uploading photos to e-Mail from Swift

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>"

Take photo and store in custom album in Xamarin.iOS

I want to take a photo and save them within a custom album on a iPad.
I tried a lot of things but ended always with wrong image orientation.
My current procedure is:
Take photo with Xamarin.Media and safe image somewhere in my app path
Create custom album if it's not existing
Load image from temporary path and save to the album
Add the image (asset) additionally to the custom album created in 2.
The workflow above is fully working except of saving the correct orientation. After loading an image with library.AssetForUrl() the containing orientation is every time up. Also after converting from asset -> CGImage -> UImage (uiImage.Orientation).
In step 3 I tried to set the orientation the the appropriate one with
var image = new UIImage(tempImage.CGImage, 1.0f, UIImageOrientation.MyOrientation)
and also with the save command
library.WriteImageToSavedPhotosAlbum(image.CGImage, myOrientation, SaveCompletionBlock)
But the orientation is still ignored. I checked this by opening the Album application as well as loading the file in my self written gallery app.
I want to avoid the use of the iOS picker to take photos. This will produce a mess of code!
Or is there any third party library which allows to take photos and store them in a custom album? Which takes care of all the metadata information? It doesn't matter if it's written in objective-c or c#. I will create bindings for it. But it's awful to work with the camera and albums in iOS.
There are tons of hand-made UIImagePickerController alternatives. Some of them:
https://github.com/w5mith/WSAssetPickerController
https://github.com/chute/photo-picker-plus-ios
https://github.com/B-Sides/ELCImagePickerController

Save photo to camera roll with specific filename

What I try to achieve is to take a photo and let the user specify if the photo belongs to category 1 or category 2. I have 2 buttons, one for each category. When the user presses the button, the photo is saved to the camera roll. AFterwards, at home, when I sync my iPad with iPhoto, I want to be able to sort by category, or at least identify to with category it belongs...
I first thought of the following :
1) taking a photo using the iPad camera -- this is already done in my app
2) saving the photo in camera roll under a specific name, such as cat1_pict123.jpg or cat2_pict456.jpg
I would plan to use
UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil );
but I don't know how / or if it is possible to specify a file name ?
Alternatively, is there a way to "tag" a photo before saving it to camera roll ? A comment or something else, which will be visible in iPhoto ?
Thank you for your help
You can't use file names for images saved in photolibrary.
Save that to Document directory with specific name.
There is a way to kinda do that, by setting the image IPTC metadata:
Set the field "Object Name" to set the image title in
iPhoto.
Set the field "Keywords" to set the keywords in
iPhoto, then use a smart album to see all the images with these
keywords.
See details (and code) at http://ootips.org/yonat/how-to-set-the-image-name-when-saving-to-the-camera-roll/ .
That's not possible right now.

Change image of three20 TTTableImageItem programmatically

i am using a TTTableViewController (three20 framework) for displaying user profile data (username, user image, etc.).
The tableview datasource is set up as follows:
_profileImageItem = [TTTableImageItem itemWithText:#"Change Profile Image" imageURL:DEFAULT_PROFILE_IMG URL:#"tt://photoThumbs"];
self.dataSource = [TTSectionedDataSource dataSourceWithObjects:
#"Profile Image",
_profileImageItem,
#"Profile Name",
_profileName,
...,
...];
When the user tabs the _profileImageItem, a UIImagePicker view is presented where the user can select a new image. After that i scale the image down and write it to the apps document folder.
My problem now is: How can i update the image URL in the datasource? Currently it still points to DEFAULT_PROFILE_IMG. Even when i update the _profileImageItem member using:
[_profileImageItem setImageURL:#"new URL here"];
the old image is shown. I have tried refreshing the view - same problem.
Any help is much appreciated.
Ok i made a stupid mistake.
TTURLCache was enabled and i updated only the image, not the path (i.e. i have overwritten the profile image). As the path is used as a key in the TTURLCache, the cache returned the cached image ;)
[[TTURLCache sharedCache] setDisableImageCache:YES];
solves the issue.

Resources