I am new in Ios & learning It.
I am creating application based on images.
I have multiple images in my viewcontroller, Which i had passed throgh another view controller(Named as a View2) via Nsuser default as below.
NSString *str11 = [[NSUserDefaults standardUserDefaults]stringForKey:#"Vishal"];
NSLog(#"%#",str11);
if(![str11 isEqualToString:#""])
{
img12 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:str11]];
img12.frame = CGRectMake(0, 0,100,100);
[secondview addSubview:img12];
[self.view addSubview:secondview];
Here In key "Vishal" I have bunch of 5 images.
Which i passed to Uiimageview *img12 in my view controller.
which i had push to my view controller.
I want to zoom these images.
Now I want to assign pinch zooming to all my images.
I had listen like You have to provide another view for Zooming.
now i am stuck at how to assign view to every images which are comes from another viewcontroller.
And how i knew which image user is tryng to pinch zooming.
Please Help me.
If you are dealing with multiple images, you will need to have a separate view for this purpose. I am providing all the steps:
Steps:
You need to create a separate view.
Add scrollview on is nibt.
Add an imageview on scroll view.
Add all zoom delegate methods, for zoom feature, in this class only like viewForZoomingInScrollView etc.
In viewForZoomingInScrollView return this imageview.
Now where you were adding images
In you image array loop create separate instance of this new class.(Suppose you have five images you will have to create five instances)
Add those images to this new class's imageview.
Now you are able to add zoom separately on every images without bothering how many images you have.
With this approach you can optimize your code as well. Suppose you will have more than 10 images , thet you can load only two instances of this class and reuse those view turn by turn according to your need, to show the images when user swipes.
Related
I am making an application that contains few layers on the image. This effect layers are children of UIView - EffectsLayerView. Effect1View, Effect2View and Effect3View are inside and few of them has UITextView. Those text views has UIPanGestureRecognize - I want to move them around the screen.
The structure looks like that
<EffectsLayerView>
<Effect1View>
<UITextView>
<Effect2View>
<Effect3View>
<UITextView>
Unfortunately only that last one (Effect3View) receive touch and move the textView. UIGestureRecognizers are added to those text views. How it should be done to make it working? Every EffectView and EffectsLayerView has their classes.
I will be glad for help.
There are 2 requiremets:
1) For every view: self.isUserInteractionEnabled = true
2) Every view mush have an unique instance of UIGestureRecognizer
I was wondering what is the best practice for this very common action:
Say i have a collection view, and each cell of this collection view has an imageView that receives a url for an image.
The images are large, so i want to preload all the images in advance (or say 5 in advance).
I'm using AFNetworking imageView Category.
So here's what i did - creating a temp UIImageView and set the url to it each iteration, but it seems not to be working right. (the images still takes time to show up, while i want it to be instantly, and if i close the internet connection, the images do not load from cache).
- (void)preloadGalleryImages {
for (GalleryItem *item in _galleryItems) {
UIImageView *tempImageView = [[UIImageView alloc] init];
[tempImageView setImageWithURL:item.imageURL placeholderImage:IMAGE(#"placegolder")];
}
}
}
Thanks,
There is a universal way of preheating images in collection views that was implemented in one of the Apple PhotosKit samples. You can anticipate user actions and fetch images that might soon appear on the display (that are close to the viewport). This feature is implemented in Nuke and DFImageManager.
I have a working IPad App. I built everything on a default white screen and I want to add an image to background of the image. I read a couple of articles and most of the suggest to create a new UIImage with the background image and stretch it to the full screen. I tried that but I am using a couple UIImage to display the photos taken and my UIImage s seem to stay at the back of the background and they don't get shown.
What is the proper way to set the background of IPad App?
this is the screenshot of my IPad App
Follow these steps :
1) Add UIImageView to your UIView.
2) Fill it with your Background UIImage.
3) Select your Background UIImageView and Select "Send to Back" Option....
The key is your view hierarchy. If you do not want to hassle around with moving the subviews along and sendings ome to back and some to front, then start with a proper view hierarchy from the beginning.
Basic rules are: the subviews overlay their superviews.
If siblings overlay each other, then the last one added is shown.
Your view hierarchy could be:
\UIView (A: the underlying self.view from the view controller's point of view.)
\UIImageView (B: the view for your background image. Empty or hidden from start.)
\UIView (C: Container for all of your views, no background color, no background image)
\UIImageView (C1: One of your picuters)
\UIImageView (C2: One of your picuters)
\UIImageView (C3: One of your picuters)
\UILabel (C4: One of your labels)
\ ...
Build up your view hierarchy. And when you need to add or change the background then assign the appropriate UIImage ot the View B.
Certainly, there is more than one way to achieve this. However, I personally thinkthat some proper view hierarchy works best, regardless whether you do that in IB or programmatically.
The proper way is to create a UIImageView and set it to the size of your view, and put all the others View in fron of it. The tutorials that you read are giving you the right way.
If you do not want to add an image, only a color you can set the background color of your view to this color.
You can use this code to send the ImageView to the back:
[self.view sendSubviewToBack:YouBackgroundImageView];
EDIT
Because you posted and XIB screenshot:
Your background image view must be in the first position, like this image:
I have an srollview with many images. After some image had touched I should open new view controller with this image and related images for image that was touched.
Now I use pushViewController.
So question is. Is it possible to open new viewController wiht zoom animation?
i.e. after user touched image, this image is zooming into the center of the screen (and this is new viewController already)
If it's possible please let me know with what I can realise it.
Thanks
I have good news and bad news for you. The good news is yes, it can be done! The bad news is that it can be complex.
The way I ended up doing it was as follows
when the user taps the image, you know what image to zoom, and you grab a reference and a frame
overlay a new view over the current view containing the scrollView, then add a NEW UIImageView containing another UIImage of the one the user tapped (could even be a higher resolution version)
animate that view to fill the screen (this image can be in a zoomable scrollview too, that's for future work!)
when you want to dismiss, you animate the frame down to be exactly whats in the scrollView, then you remove the overlay view
now users is more or less back to where they were before the tap
i have 3 images in my display where i use CoreData to store them images and to view them in the display. Now i would like to touch these images and it goes large in another view. Ive tried using touch events bt nothing seems to work. Can anyone assist me please
You can put a transparent UIButton over the image and declare a IBAction on the button and get the image according to button tag. Then pass the image to next controller.