Note that there are some explanatory texts on larger screens.

plurals
  1. POChange image of a scrollview or replace the array of images
    primarykey
    data
    text
    <p>I have a problem with changing images in the scrollview, the scrollview problem is that depending on the action that makes me have to change the image that contains other, as I do not change the picture or the array of images, I need help, thanks</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; NSMutableArray *imgNames = [[NSMutableArray alloc] initWithObjects:@"cooper.png", @"cabrio.png",@"country.png", nil]; NSMutableArray *imgArray = [[NSMutableArray alloc] init]; UIImageView *tempImageView; for(NSString *name in imgNames) { tempImageView = [[UIImageView alloc] init]; tempImageView.contentMode = UIViewContentModeScaleAspectFit; tempImageView.image = [UIImage imageNamed:name]; [imgArray addObject:tempImageView]; } CGSize pageSize = scrollView.frame.size; NSUInteger page = 0; for(UIView *view in imgArray) { [scrollView addSubview:view]; view.frame = CGRectMake(pageSize.width * page++ + 10, 0, pageSize.width - 20, pageSize.height); } scrollView.contentSize = CGSizeMake(pageSize.width * [imgArray count], pageSize.height); } - (IBAction)btnAction:(id)sender { NSMutableArray *imgNames = [[NSMutableArray alloc] initWithObjects:@"hello.png", @"bye.png",@"trues.png", nil]; NSMutableArray *imgArray = [[NSMutableArray alloc] init]; UIImageView *tempImageView; for(NSString *name in imgNames) { tempImageView = [[UIImageView alloc] init]; tempImageView.contentMode = UIViewContentModeScaleAspectFit; tempImageView.image = [UIImage imageNamed:name]; [imgArray addObject:tempImageView]; } CGSize pageSize = scrollView.frame.size; NSUInteger page = 0; for(UIView *view in imgArray) { [scrollView addSubview:view]; view.frame = CGRectMake(pageSize.width * page++ + 10, 0, pageSize.width - 20, pageSize.height); } scrollView.contentSize = CGSizeMake(pageSize.width * [imgArray count], pageSize.height); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload