如何用更少的内存和CPU负载在iPad上滑动图像更改?

如何用更少的内存和CPU负载在iPad上滑动图像更改?,ipad,memory,cpu,swipe,Ipad,Memory,Cpu,Swipe,我的应用程序有大约100张图片。每张图片大约150 KB。我只想滑动每张图片以转到下一张或回到上一张图片 使用更少内存和CPU负载的最佳方法是什么?假设应用程序中有所有映像,所有映像名称都存储在NSMutableArray中 取一个UIImageView作为您的XIB文件上的IBOutlet连接 NSMutableArray *imgNameArr; //Array to store image names NSInteger currShowing; //Integer value to ke

我的应用程序有大约100张图片。每张图片大约150 KB。我只想滑动每张图片以转到下一张或回到上一张图片


使用更少内存和CPU负载的最佳方法是什么?

假设应用程序中有所有映像,所有映像名称都存储在NSMutableArray中

取一个UIImageView作为您的XIB文件上的IBOutlet连接

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]];
    }
}
NSMutableArray*imgNameArr//用于存储图像名称的数组
NSInteger-currshing//整数值,用于跟踪当前显示的图像。
//向右滑动时更改图像的功能
-(无效)swipeRight
{
如果(当前显示0)
{
电流-=1;
self.yourDisplayImageView.image=[UIImage ImageName:[imgNameArr对象索引:currShowing]];
}
}
如有任何疑问,请留下评论

希望能有帮助