Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Access Particular view of a pageControl viewController?
    text
    copied!<p>Hi I m creating a project where multiple Images Loading from Server With some like Count and Comment Count and a Button to like the image. I m showing the individual Images With using a Slider Controller like PageControl.</p> <p>this is My code for Showing the View</p> <pre><code>-(UIView*)reloadView:(DPSliderView *)sliderView viewAtIndex:(NSUInteger)idx { _loading_view.hidden=TRUE; if (idx &lt; [photos count]) { NSDictionary *item = [photos objectAtIndex:idx]; PhotoView *v = [[PhotoView alloc] init]; v.photoIndex = idx; v.imageView.imageURL = [DPAPI urlForPhoto:item[@"photo_220x220"]]; NSString *placename1 = [item valueForKeyPath:@"spotting.item.name"]; NSString *firstCapChar1 = [[placename1 substringToIndex:1] capitalizedString]; NSString *cappedString1 = [placename1 stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:firstCapChar1]; v.spotNameLabel.text = cappedString1; NSString *placename = [item valueForKeyPath:@"spotting.place.name"]; NSString *firstCapChar = [[placename substringToIndex:1] capitalizedString]; NSString *cappedString = [placename stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:firstCapChar]; NSString *place1=[NSString stringWithFormat:@"%@",cappedString]; NSString *address=[NSString stringWithFormat:@"%@",[item valueForKeyPath:@"spotting.place.address"]]; NSString *location_str3 = [NSString stringWithFormat:@"@ %@, %@",place1,address]; int cap_len=[place1 length]; int address_lenth=[address length]; ZMutableAttributedString *str = [[ZMutableAttributedString alloc] initWithString:location_str3 attributes:[NSDictionary dictionaryWithObjectsAndKeys: [[FontManager sharedManager] zFontWithName:@"Lucida Grande" pointSize:12], ZFontAttributeName, nil]]; [str addAttribute:ZFontAttributeName value:[[FontManager sharedManager] zFontWithName:@"Lucida Grande" pointSize:12] range:NSMakeRange(0, cap_len+3)]; [str addAttribute:ZForegroundColorAttributeName value:[UIColor colorWithRed:241/255.0f green:73.0/255.0f blue:2.0/255.0f alpha:1.0]range:NSMakeRange(0, cap_len+3)]; [str addAttribute:ZForegroundColorAttributeName value:[UIColor colorWithRed:128.0/255.0f green:121.0/255.0f blue:98.0/255.0f alpha:1.0]range:NSMakeRange(cap_len+4, address_lenth)]; v.placefontlabel.zAttributedText=str; v.likesCountLabel.text = [NSString stringWithFormat:@"%i", [item[@"likes_count"] intValue]]; if ([_device_lang_str isEqualToString:@"es"]) { v.shightingsLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i Vistas", nil), [item[@"sightings_count"] intValue]]; } else { v.shightingsLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i Sightings", nil), [item[@"sightings_count"] intValue]]; } if ([nolocationstr isEqualToString:@"YES"]) { v.distanceLabel.text =[NSString stringWithFormat:@"%.2f km", [item[@"distance"] floatValue]]; } else { CLLocation *location1 = [[CLLocation alloc] initWithLatitude:[[item valueForKeyPath:@"spotting.place.lat"]floatValue] longitude:[[item valueForKeyPath:@"spotting.place.lng"] floatValue]]; CLLocation *location2 = [[CLLocation alloc] initWithLatitude:[_explore_lat_str floatValue] longitude:[_explore_lng_str floatValue]]; NSString *lat_laong=[NSString stringWithFormat:@"%f",[location1 distanceFromLocation:location2]]; int km=[lat_laong floatValue]*0.001; NSString *distancestr=[NSString stringWithFormat:@"%d km",km]; float dist=[distancestr floatValue]; v.distanceLabel.text = [NSString stringWithFormat:@"%.2f km", dist]; } if (![item[@"likes"] boolValue]) { v.likeButton.enabled = YES; v.likeButton.tag = idx; [v.likeButton setImage:[UIImage imageNamed:@"like_new.png"] forState:UIControlStateNormal]; [v.likeButton addTarget:self action:@selector(likeAction:) forControlEvents:UIControlEventTouchUpInside]; } else { v.likeButton.tag = idx; [v.likeButton setImage:[UIImage imageNamed:@"like_new1.png"] forState:UIControlStateNormal]; } NSArray *guides = item[@"guides"]; if ([guides count] &gt; 0) { NSString *guideType = [[guides objectAtIndex:0] valueForKey:@"type"]; UIImage *guidesIcon = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png", guideType]]; v.guideButton.hidden = NO; v.guideButton.tag = idx; [v.guideButton setImage:guidesIcon forState:UIControlStateNormal]; [v.guideButton addTarget:self action:@selector(guideAction:) forControlEvents:UIControlEventTouchUpInside]; } v.shareButton.tag = idx; [v.shareButton addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside]; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoTapGesture:)]; [v addGestureRecognizer:tapGesture]; [tapGesture release]; return [v autorelease]; } else { UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sc_img.png"]]; UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; indicator.center = CGPointMake(CGRectGetMidX(iv.bounds), 110); [indicator startAnimating]; [iv addSubview:indicator]; [indicator release]; return [iv autorelease]; } } </code></pre> <p>Now My question is :</p> <p>If i will Click on Like Button , Then i have to change the button image as well as like count. I can able to Change the Button Image By This Method </p> <pre><code>[sender setImage:[UIImage ImageNamed:@"image.png"]]; </code></pre> <p>But How can I change the Like count of the Label ? How can i access the Particular label of the View ? I have assigned the tag But , I dont know how to assign it.I dont want to Reload Whole Slider as the Photo are loading from Network (Remote Server) . Thanks for your Time. </p>
 

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