Title: class with multiple xib or more classes?
Tags: iphone;objective-c;uiimageview;uiimage
Question: in my application, I made a transition from FirstViewController to FormViewController.
[self presentModalViewController:formViewController animated:YES];
in FormViewController I want to display four images, each time the user clicks an image, I note the number or the name of the image clicked in a dictionary and I display the four next images. So, there are about 8 sets of 4 images.
So my questions are, each four images shoul be showed in a new class, or i should put all the images in FormViewController and use .hidden ?
it's possible to make an animation when changing images ? not an animation of all the view , only the images.

Here is the accepted answer: I'd use a single xib and a single class. The class needs some kind of data model to hold the list of available images, the previously chosen images and the current visible ones.
When the user clicks an image, update the data and show new ones with something like this to fade-out old image and fade-in the new one.
/* ARC code */
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
/* destroy the transition view, set the image first */
UIImageView *transitionImageView = (UIImageView *)context;
self.pic.image = transitionImageView.image;
[transitionImageView removeFromSuperview];
transitionImageView = nil;
- (void)clickHandler:(id)sender {
/* temporary view for the animation */
UIImageView *transitionImageView = [[UIImageView alloc] initWithFrame:self.pic.frame];
transitionImageView.image = <# new UIImage #&gt;;
transitionImageView.alpha = 0.0f;
[self.view addSubview:transitionImageView];
[UIView beginAnimations:@"UpdateImages" context:transitionImageView];
[UIView setAnimationDuration:2.0f];
transitionImageView.alpha = 1.0f;
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
Adapt it for your four images.
If you want more fancy animations you can have two sets of 4 UIImageViews and use them to show and animate the image transitions.

Here is another answer: you can show the images in the same class and personally I believe that is what u shud do as it will be easier to manage ur code , and yes you can animate the image changes.
Comment for this answer: Ok thank you but i have another question :) how to use image as button ? and i can animate UIImage change ?
Comment for this answer: add a gesture recognizer on the image Views to accept single taps... this way you can make it act as a button

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:12/17/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<iphone><objective-c><uiimageview><uiimage>', 'Title': 'class with multiple xib or more classes?', 'ViewCount': 84, 'id': 8544398, 'user_AboutMe': '', 'user_AccountId': 396509.0, 'user_DisplayName': 'user567', 'user_Reputation': 3468.0, 'user_Views': 390.0, 'user_id': 760095.0}}