开发者

How to swipe image change on iPad with less memory and CPU load?

开发者 https://www.devze.com 2023-03-05 09:47 出处:网络
My app has around 100 Picture. Each picture is around 150 KB.And I just want to swipe each picture to开发者_如何学JAVA go next or back to previous pic.

My app has around 100 Picture. Each picture is around 150 KB.And I just want to swipe each picture to开发者_如何学JAVA go next or back to previous pic.

What is the best way that use less memory and CPU load ???


Assuming you have all images within application, all image names stored in NSMutableArray.

Take one UIImageView wired up as IBOutlet on your XIB file.

NSMutableArray *imgNameArr; //Array to store image names
NSInteger currShowing; //Integer value to keep track of image currently being displayed.

//Function to change image when swipe right
-(void)swipeRight
{
    if(currShowing<[imgNameArr count])
    {
        currShowing+=1;
        self.yourDisplayImageView.image = [UIImage imageNamed:[imgNameArr objectAtIndex:currShowing]];
    }
}

//Function to change image when swipe left
-(void)swipeLeft
{
    if(currShowing>0)
    {
        currShowing-=1;
        self.yourDisplayImageView.image = [UIImage imageNamed:[imgNameArr objectAtIndex:currShowing]];
    }
}

Please do leave comment for any query.

Hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号