iphone - Transfer Array index to next controller -


i have 1 array.getting images array want transfer array index next method how can this.

my code:-

frontscards =[[nsmutablearray alloc]initwithcapacity:13];     [frontscards insertobject:@"cloub1.png" atindex:0];     [frontscards insertobject:@"cloub2.png" atindex:1];     [frontscards insertobject:@"cloub3.png" atindex:2];     [frontscards insertobject:@"cloub4.png" atindex:3];     [frontscards insertobject:@"cloub5.png" atindex:4];     [frontscards insertobject:@"cloub6.png" atindex:5];     [frontscards insertobject:@"cloub7.png" atindex:6];     [frontscards insertobject:@"cloub8.png" atindex:7];     [frontscards insertobject:@"cloub9.png" atindex:8];     [frontscards insertobject:@"cloub10.png" atindex:9];     [frontscards insertobject:@"cloub11.png" atindex:10];     [frontscards insertobject:@"cloub12.png" atindex:11];     [frontscards insertobject:@"cloub13.png" atindex:12]; 

randomly fetched images , store imageview scroll vertically

    randidx=arc4random()%[frontscards count];      nsstring *imagename=[frontscards objectatindex:randidx];     [imgview setimage:[uiimage imagenamed:imagename]]; 

if user douuble tapped on cloub12.png image want genrate 11 index value , transfer next view controller. if user tapped cloub4 index genrate 3

how may in advance.

set property, , synthesize in nextviewcontroller

@property(nonatomic)nsinteger tagvalue;

first set tag imageview

[imgview settag:randidx];  

add gesture rec yourimageview

uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handleimagetap:)];      tap.cancelstouchesinview = yes;      tap.numberoftapsrequired = 2;      tap.delegate = self;      [imgview addgesturerecognizer:tap]; 

then on double tapgesture , tag value of yourimage then

// handle method

- (void) handleimagetap:(uigesturerecognizer *)gesturerecognizer {     uiimageview *imageview = (uiimageview *)[gesturerecognizer view];     nslog(@"pass tag=%d",image.tag);      nextviewcontroller *nvc=[[nextviewcontroller alloc]initwithnibname:@"nextviewcontroller" bundle:nil];     nvc.tagvalue=yourimageview.tag;     [self.navigationcontroller pushviewcontroller:nvc animated:yes];  } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -