1. Use arrays to traverse images in a folder,CodeAs follows:
Nsfilemanager * filemanager = [nsfilemanager defaultmanager];
Nsarray * paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes); nsstring * documentsdirectory = [paths objectatindex: 0]; Nslog (@ "% d", [paths count]); Nserror * error = nil; Nsarray * filelist = [[nsarray alloc] init]; Nsmutablearray * filepath = [nsmutablearray arraywithcapacity: 100]; Nsmutablearray * imgarray = [nsmutablearray arraywithcapacity: 200]; // Nsarray * filepath = [[nsarray alloc] init]; Filelist = [filemanager contentsofdirectoryatpath: documentsdirectory error: & error]; For (nsstring * file in filelist ){ Nslog (@ "filename is: % @", file ); [Filepath addobject: [documentsdirectory stringbyappendingpathcomponent: file]; } For (INT I = 0; I <[filelist count]; I ++ ){ Uiimage * temp = [uiimage imagewithcontentsoffile: [filepath objectatindex: I]; [Imgarray addobject: temp]; } [Imgview1 setimage: [imgarray objectatindex: 0]; [Imgview2 setimage: [imgarray objectatindex: 1]; [Imgview3 setimage: [imgarray objectatindex: 2]; [Imgview4 setimage: [imgarray objectatindex: 3]; [Imgview5 setimage: [imgarray objectatindex: 4]; [Imgview6 setimage: [imgarray objectatindex: 5]; [Imgview7 setimage: [imgarray objectatindex: 6]; [Imgview8 setimage: [imgarray objectatindex: 7]; [Imgview9 setimage: [imgarray objectatindex: 8];