Purva
Purva

Reputation: 1291

Dragging image in touches moved gets slow

I am working in an app in which i need to drag the images(i have more than 100 images).Now it is working fine in ios 5 but when i use that same code for ios6 ,it works fine in simulator but slow down in device,It moves quite jerky. What can i do to move the images smoothly.

Upvotes: 2

Views: 382

Answers (1)

Nitin Gohel
Nitin Gohel

Reputation: 49730

For 100's of image you must implement lazy loading or asynchronous task using SDWebImage like Bellow:-

As per my suggestion I am doing asynchronous using SDWebImages A Link of GitHubproject

And I configure this like below steps:-

  • you need to first right click on your project name:->add files to yourProject-> selected SDWebImageproject and add them

NOTE:- please do not check copy option

  • now click on project name in Your xcode going to build phases:->target dependencies:-> click on + button and add SDWebimage ARC

  • now select link binary with library click + button add libSDWebimageARC.a and again click + and add imageIO.framework and also add libxml2.dylib thats it

    going to Build setting:->other link flag:-> add -ObjC

    and header search path add this three item

    1 /usr/include/libxml2

    2 "$(OBJROOT)/UninstalledProducts/include"

    3 "$(TARGET_BUILD_DIR)/usr/local/lib/include"

now build and run its working like smoothly cheers.... :)

It's more easy and very useful task for loading images and its store catch also so you got more speedy work.

And you can asynchronous images with just two line of code like

In .m :-

#import <SDWebImage/UIImageView+WebCache.h>

 NSString *strUrlSting =[d valueForKey:@"Current_RequestUser_Image"];
        strUrlSting =[strUrlSting stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
        NSURL* url = [NSURL URLWithString:strUrlSting];

        [imgView_user1 setImageWithURL:url
                      placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

and for Move image related demos and links please download this demo and check it :-

https://github.com/elc/iCodeBlogDemoPhotoBoard

hope it's help's you

here are some same Asked Question please visit link:-

Drag + Rotation using UIPanGestureRecognizer touch getting off track

swapping images using pan gesture

How to use UIPanGestureRecognizer to move object? iPhone/iPad

Upvotes: 3

Related Questions