I am using a customized cell to show an image. But, when I add a picture to the first line, it gets loaded every fourth row. What could be the problem? I am using the uiimagepickercontroller to lift the image from the iFile Photo Library and give it to the first cell of the table.
- (zero) Image Picture Controller: (UIImagePickerController *) Picker didFinishPickingImage: (UIImage *) Image EditingInfo: (Encryption *) EditingInfo {CGSEewsNews = CGSIMMake (80, 80); UIGRIFIiBIGIJJC Contex (NUCIES); [Image DrawRector: CGRactMake (0,0, new size.width, new size. Hi)]; UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext (); ImageView.image = newImage; [Picker Dismmandmodl Vij Niyntrkanumti: YES]; } - (NSInteger) numberOfSectionsInTableView: (UITableView *) tableview {return1; } - (UITableViewCell *) TableView: (UITableView *) Table View CellForOutPath: (NSIndexPath *) Index Pathway {Fixed NSString * CustomCellIdentifier = @ "CustomCellIdentifier"; Customcell * cell = (customcell *) [TableViewRequiredCalViewidentifier: customsendifier]; If (cell == zero) {NSArray * nib = [[NSBundle mainBundle] loadNib nominated: @ "customcell" owner: zero option: zero]; (Id current object niB) {if ([currentObject isKindOfClass: [CustomCell class]]) {cell = (CustomCell *) currentObject; // [cell loadflow comments: [Latest FML Commands ObjectAntx: IndexPath.ro]]; break; }}} NSUInteger r = [index line]; NSUnitor S = [IndexPath section]; // [cell settext: [NSString stringWithFormat: @ "I have cell% d", indexPath.row]]; // NSInteger r = indexPath.row; If (R == 1) if (S == 0) {UIImage * img = imageView.image; Cell.imageView.image = img; } Return cell; }
iPhone SDK UITableView
optimization UITableViewCell < / Code> Constructed using cells that are not visible at all time instead of re-creating new ones, this is the dequeueReusableCellWithIdentifier:
of your call.
In the tableView: cellForRowAtIndexPath:
is done through, you need to make sure that you have approved the cell containing the dequeue, so it only gives new cell contents In this case, if your before is cell.imageView.image = nil
(r == 1) ...
the statement will be sufficient.
No comments:
Post a Comment