How to "transfer" UIImageView between view - iphone

when you click "Share" in my app you'll show an ActionSheet like this:
Take photo
Select photo from Library
Cancel
You tap "Take photo" and you'll see an ImagePicker, with "presentModalViewController".
You take a photo and you select "OK" in the ImagePicker.
Here, I want the photo just taken in a new view with other label. Like this:
(new view)
Little photo (just taken)
- Label 1 (ex. Title of photo)
- Label 2 (ex. Location of photo)
and a button "Share" for sharing your photo and its infos.
How can I do this? I'm stopped after take the photo. How can I send my photo (in a imageview) to another view?
Thanks

for this,
make some global varible in appDelegate class and make them property.
for saving Image make UIImage object in app delegate and for title and path make string variables and make all these : property then.
then when you select image from modelView at the selection time you must set app delegate properties(image,title,path).and navigate to other page and on viewWillAppear of new page
set your controls (ImageView and labels) by these objects.
I hope, it helps you. You need to code this logic.

Some one already suggested for that by using appDelegate.
you can do in other way too.
just declare some variable like imagePath and imageTitle in the 2nd view controller. and set property to them like
#property (nonatomic,retain) NSString *imagePath;
And then in the 1st view controller access those variables like
secondViewControllerObj.imagePath = #"Give Image Path Here";
then you can access the imagePath in the 2nd View Controller as self.imagePath
Regards,
Satya

Related

Mac OS - Change Status Item Button Image

I want to update the image when the user clicks something in the application but I can't get it to work.
The status item with the menu is defined in the AppDelegate. I am trying to update the image in the ViewController with this piece of code which I think should work:
AppDelegate().statusItem.button?.image = NSImage(named:NSImage.Name("icon-orange"))
No errors are showing up, but turns out it still doesn't work, so is it possible to change the image or am I doing something wrong?
AppDelegate() creates a brand new instance which is not the delegate class in Interface Builder.
You need the real reference:
(NSApp.delegate as! AppDelegate).statusItem.button?.image = NSImage(named:NSImage.Name("icon-orange"))

Three20 TTLauncherItem in a custom position

When I add a new TTLauncherItem icon to a TTLauncherView, this icon is set at the last position. Could I set it in another position? How should I do it?
Subclass TTLauncherView and override...
- (void)addItem:(TTLauncherItem*)item animated:(BOOL)animated;
If you look at that method in TTLauncherView, you can see how it's getting the page to add to by using...
NSMutableArray* page = [self pageWithFreeSpace:self.currentPageIndex];
So instead of doing that you can pick the first page or whatever. Once you have the page you want to add to you can put the item wherever you want. Page is just an NSMutableArray of TTLauncherItems.

Trying to play with the annotation and bubble callout on mkmapview

I am developing an application in iphone which deals with maps. I have many annotations. I need different images to be loaded in the callout bubble.It mean user can edit the callout it may be image and He also type text on callout bubble .How can I give give multiple action on the callout bubble .
And most important think is that this annotation must drop on the map after clicking the save button. For Example I have two class (mapview And photoview),And in photoView i have three button (chooshphoto,takephoto,usephoto)when user take photo or browse for photo and he want use this photo.When he click on usephoto button the annotation must drop after that.And display onthe mapView.
The second half of your question isn't very clear but I'll try and answer the first.
The only real customisation you can apply to the callout view for an MKAnnotation is to set the Title, subtitle labels and the left/right calloutAccessoryViews. You can set the latter to images or callOutAccessoryViewIndicators, or another UIView but it can't be taller than 32 pixels.
MKAnnontationView documentation
That's really about it I'm afraid. For anything more advanced than that, you'll have to create a custom implementation. This blog post should be helpful, I plan on building something similar myself.
MKPinAnnontationView can be set to drop on the map as you describe so as long as you're happy with the Pin image for the annontation view itself, you can simply set it's animatesDrop property to YES and it will animate onto the map when it's added.
MKPinAnnontationView documentation
EDIT: I think this is what you want;-
In your mapView controller, define a property to hold the object you want to animate.
#interface MyMapViewController {
Photo *photoToAnimate;
}
#property (nonatomic, retain) Photo *photoToAnimate;
#end
Then in your implementation file, add the following to ViewDidAppear
-(void)ViewDidAppear {
...
if (photoToAnimate) {
[mapView addAnnotation:photoToAnimate];
self.photoToAnimate = nil; // reset it for the next time
}
...
}
Then in your PhotoViewController, simply set the property on the button press
-(void)usePhotoAction {
...
mapViewController.photoToAnimate = photo;
...
}
At least that's the really simple hacky way of what I was trying to describe in the comments. ViewDidAppear will fire when the MapView re-appears and it will add the pin to itself accordingly. If you need to add more than one pin, use an array to store them and iterate through the array.
There might be better patterns for this but in short, your MapView needs to get hold of the object you want to drop somehow and then not actually do anything with it until ViewDidAppear is called.

iPhone - detailView controller

I am having a tableView which lists the contents directory which includes jpg, pdf, zip, mp3, mp4, sql,.. files and even folders. In the next step, I am having a detailView which displays some properties of the selected file such as fileName, fileSize, filePath, fileType. Everything works perfect.
But actually my plan is to include a additional option in the detailView.
That is,
If the selected file in the tableView is a image file, it should open a imageView in the detailView to display that image.
If the selected file is a mp3, it should open a player to play the song in the detailView.
If the selected file is a video or mp4 file, it should open a player to play that video in detailView.
If the selected item is a folder, it should again open a tableView which dispalys the contents of the folder.
For other files, it should push a alertView regarding that it is a unknown file.
Hope my concept was narrated well. I got the methods for playing the .mp3 and .mp4 files. Now I am stuck in pushing the imageView and in case of a folder. I have no ideas to proceed both the methods.
This is my tableView
This is my detailView for video file
This is my detailView for a .mp3 file
This is the detailView left empty for my imageView.
Please help me to proceed with some sample codes. Thank you in advance.
Judging by your screenshots and progress of implementing the other filetypes, I assume you are able to pass the information of the file path to the detail view. So, for the image file, I am going to discuss how to display it into a UIImageView.
For the image view, You will want create a UIImage with the path.
Code example below: Assume that pathString is an NSString* with the image path, and that imageView is now a UIImageView which should display the image. This code would reside in the -viewDidLoad method of the detailViewController handling the image display.
UIImage* theImage = [[UIImage alloc] initWithContentOfFile:pathString];
imageView.image = theImage;
[theImage release];
As for the folder view, this is a bit different. For the best result you will want to recursively load the tableViewController you are using to display the list of files now (so that it will inherit all the file/folder handling recursively).
I would suggest to add an instance variable like folderPath to the tableViewController that you set before actually pushing the view. And the tableViewController should use this as the base path.
Code example below: Assume that pathString is an NSString* with the destination path, and that detailViewController is now an instance of the new tableViewController to be opened. This code would reside in the method that will create the new detailViewController to be displayed, somewhere within tableView:didSelectRowAtIndexPath:
detailViewController.folderPath = pathString;
[self.navigationController pushViewController:detailViewController animated:YES];
You should then implement in the -viewDidLoad method of the tableViewController, on what folder content should be read from the folderPath instance variable.
This method - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
is called when there is touch occurred on some cell.
You can get cell with [yourTableView cellForRowAtIndexPath:cellIndex];
After that you can see type property, and open appropriate viewcontroller.
[self.navigationController pushViewController:detailViewController animated:YES];
When you create your detailView, you should overload the init with additional parameters that indicate the type of media to display and the url/file of this resource.
If it's for an image, look at this post

Utility Application infoButton Stays on Top

I used a utility application template to create my application, but I am using a UIImagePicker to pick some photos. The little infoButton, the i with a circle around it, shows up when the picker is displayed. If the infoButton was not in another class then I could call infoButton.hidden = YES; and it would hide it. Any ideas how to solve this problem?
Thanks,
-Pat
I took a look at the utility application template, the view controller with a gray background and an info button is MainViewController, and the instance is also the "mainViewController" property of the application delegate.
It seems that you have already created an IBOutlet to the infoButton, so, you can access the button by calling [UIApplication sharedApplication].delegate.mainViewController.infoButton .