Change image of three20 TTTableImageItem programmatically - ios

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.

Related

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

Unable to show contact image in shortcut items

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).

iOS App Issue - Can't access image from image asset catalog

I'm new to iOS development, so apologies for advance. I know this has been covered earlier but I can't seem to find anything that helps with my issue.
Its a fairly simple but annoying issue.
I have a image in assets with a file name of hollwood.png but a xcode name, "hollywood" (no png).
I am trying to set a UIImageView to display it.
So in ViewDidLoad I have the following: (imageContainer is the UIImageView IBOutlet)
- (void)viewDidLoad {
super viewDidLoad];
self.model = [Model sharedModel];
self.imageContainer.image = [UIImage imageNamed:#"hollywood"];
}
I can not get it to display the image from Assets.
I know the UIImageView outlet works correctly because I can have the app choose a photo from gallery and set the photo to UIImageView.
I'm having a very difficult time figuring out how to load the image I saved in the assets catalog into UIImageView.
I just had this issue. I had dragged the image and for some reason Xcode added a weird "Design" locale and I couldn't load the image using UIImage(named: ). I don't know if this is your case, but you can try right clicking on the image in the Asset Catalog, "Show in Finder", opening the folder and checking the "Contents.json" file. Each image there should only have the keys "idiom", "filename" and "scale".
Make sure your image is added in Compile Sources
AppTarget->Build Phases-> Compile Sources
If not try to add that and check.

How to get user profile Image in big size from Twitter timeline object in iOS

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.. :)

Adding "stretchable" images to and image selected from gallery

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

Resources