views:

80

answers:

1

Hey guys can someone help me please?

I have a popover controller that is filled with an array (detailItem) and in different xib I load an image according to the current cell selected in detailitem.

All I want is a button called nextItem which loads the next item in the array?

Cheers

-(IBAction) nextitem{       
    NSString * imageName = [NSString stringWithFormat:@"%@.jpg",detailItem];
    imageview.image = [UIImage imageNamed:imageName];       
}
A: 

Look at the Splitview templates in Xcode. The detail view controllers all have a setDetailItem: method that tells the detail view which object it is supposed to display. So, you would just load the detail view nib and then send it setDetailItem: with the object in array element of the chosen row in the popover.

Update:

Okay, then something like this:

@property (nonatomic,retain) NSArray *imageNames;
@proprty NSUInteger currentImageIndex;

-(IBAction) nextItem{  
    if (self.currenImageIndex<[self.imageNames count]) {
        self.currentImageIndex=self.currentImageIndex+1;    
        NSString * imageName = [NSString stringWithFormat:@"%@.jpg",[self.imageNames objectAtIndex:currentmageIndex]];
        imageview.image = [UIImage imageNamed:imageName];  
    }     
}

-(IBAction) previousItem{   
    if (self.currenImageIndex>0) {
        self.currentImageIndex=self.currentImageIndex-1;    
        NSString * imageName = [NSString stringWithFormat:@"%@.jpg",[self.imageNames objectAtIndex:currentmageIndex]];
        imageview.image = [UIImage imageNamed:imageName];  
    }      
}
TechZen
Hey thanks for the reply, but the problem is not loading the image from the popover but the problem is having a button for back and forward just to cycle through the images?Cheers
acdesign
See my update for how to use internal to a view controller.
TechZen