ios - is it possible to implement iCarousel with SKScene array? -


i'm working on project , want create icarousel contains different scenes details. clear, app save arenas contents in xml files skscene, , want have previews of arenas before load them. , thought icarousel solution, don' know if possible.

what is: 1-i created project storyboard contains tab bar view. 2- 1 tab used skscene , saving elements (the scene working , there switch second tab). 3- second used present icarousel, should preview arenas (maps).

can , suggest solution problem? , if icarousel choice. please tell me how it.

it's little expensive in term of storage capacity, works perfectly. here's you'll get:

the calling view of carousel

when click load arena, you'll following view select arena:

carousel view

you have select arena , click on green button return calling view chosen arena loaded.

and here's way achieve it:

 -(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {  //uitableviewcell *cell=[tableview cellforrowatindexpath:indexpath]; selecteditem=[_title objectatindex:indexpath.row]; [singleton setchoice:selecteditem];  tableselecteditemindexpath=indexpath; //here strore selected item index later when returninng normal mode can deselect item  tableviewref=tableview;  if([selecteditem isequaltostring:@"load arena]) {     if ([[spritemyscene getmapsvector] count] == 0){          uialertview * alert =[[uialertview alloc ] initwithtitle:@"absence de carte à visualiser" message:@"il n'y pas de carte disponible" delegate:self cancelbuttontitle:@"ok" otherbuttontitles: nil];         [alert show];     }      else{          [[[[self.tabbarcontroller tabbar]items]objectatindex:2]setenabled:true];          [self.tabbarcontroller setselectedindex:2 ];     } }  if([selecteditem isequaltostring:@"save arena"]) {     uialertview * alert =[[uialertview alloc ] initwithtitle:@"xml save" message:@"enter name of file wish save." delegate:self cancelbuttontitle:@"cancel" otherbuttontitles: nil];     alert.alertviewstyle = uialertviewstyleplaintextinput;     [alert addbuttonwithtitle:@"ok"];     [alert show];      //we programmarically remove selection     [tableviewref deselectrowatindexpath:tableselecteditemindexpath animated:yes];  }  if([selecteditem isequaltostring:@"delete arena"]) {     int ycoordinate=40;     //this scroll pan ein xml file list displayed     _polygonview = [[uiscrollview alloc] initwithframe: cgrectmake ( 0, 0, 500, 300)];     _polygonview.backgroundcolor=[uicolor clearcolor];     [_polygonview setscrollenabled:yes]; //we activated scroll function      nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); //here directory paths on ios     nsstring *docdir;      docdir=[paths objectatindex:0]; //this path document directory       //we array containing files in given directory. same file class in java     nsarray *directorycontent = [[nsfilemanager defaultmanager] contentsofdirectoryatpath:docdir error:null];     (int = 0; < (int)[directorycontent count]; i++)     {         nsrange range;         range=[[directorycontent objectatindex:i] rangeofstring:@".xml"];         if(range.location != nsnotfound)         {              //this index used ot exlude .xml part when displaying teh name sof files user             int toindex=[[directorycontent objectatindex:i] length];             toindex-=4;              nsstring *btntitle=[[directorycontent objectatindex:i] substringtoindex:toindex];             if(![btntitle isequaltostring:@"imagedata"])             {                 uibutton *filebutton = [[uibutton alloc] initwithframe:cgrectmake(165, ycoordinate, 200, 40)];                 [filebutton settitle:btntitle forstate:uicontrolstatenormal];                 [filebutton settitlecolor:[uicolor whitecolor]forstate:uicontrolstatenormal];                 [filebutton setenabled:yes];                 [filebutton setuserinteractionenabled:yes];                 [filebutton addtarget: self action: @selector(buttonispressed:) forcontrolevents: uicontroleventtouchdown];                 [filebutton setbackgroundcolor:[uicolor bluecolor]];                 [_polygonview addsubview:filebutton];                 ycoordinate+=45;             }         }      }      _polygonview.contentsize = cgsizemake(self.view.frame.size.width, self.view.frame.size.height *2.5);      //this licensed class used create window pane     customios7alertview* alertview=[[customios7alertview alloc]init];     alertview.tag=1;     [alertview setframe:cgrectmake(500, 0, 500, 500)];      [alertview setcontainerview:_polygonview];     [alertview setbuttontitles:[nsmutablearray arraywithobjects:@"delete file", @"cancel", nil]];     [alertview setdelegate:self];     [alertview show]; }  .... /*  * method used ot read user input text value when user enters name of xml file  * used when saving xml file  */  - (void)alertview:(uialertview *)alertview diddismisswithbuttonindex:(nsinteger)buttonindex {  if (buttonindex == 1) {      uitextfield* filename = [alertview textfieldatindex:0];      xmlhandler* xml=[[xmlhandler alloc] init];      [xml setxmlfilename:filename.text];      [[spriteviewcontroller getsceneref] snapshotscene:filename.text];      //we save image file     [xml generateimagefile:[spritemyscene getimagedata]:[spritemyscene getimagefilename]];      //this function gets _nodedictionnary argument     nsmutabledictionary* tmp = [singleton getscenenodedictionnary];      [xml generatexml:tmp];  }} 

and picture taken each time user save arena using method:

- (void) snapshotscene: (nsstring*) imagename{  uigraphicsbeginimagecontextwithoptions(self.view.bounds.size, no, 0.50); [self.view drawviewhierarchyinrect:self.view.bounds afterscreenupdates:yes]; uiimage * image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();  @autoreleasepool {      //convert image .png format.     imagedata = uiimagepngrepresentation(image);      imagefilename= imagename;      [mapsvector addobject: imagedata];     [filenamesvector addobject: imagefilename];   } 

}

for icarousel class, use link: the icarousel repository hope help.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -