ios - UITableView's cell doesn't work as setting -


I have set the utility cell as the following

  - (UITableViewCell * ) Table view: (UITableView *) Tableview CellularUritindpath: (NSINXPath *) IndexPath {Static NSSTING * Cell Identifier = "Sale"; DetailCell * cell = [Table view deserves reusable CellWithIdentifier: CellIdentifier]; If (cell == blue) {cell = [[extension alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier]; } If (indexPath.row == 0) {cell. Background color = [UIColor redColor]; UIImageView * bigphoto = [[UIImageView alloc] initWithFrame: CGRectMake (0, 0, 320, 320)]; Bigphoto.image = [UIImage imageNamed: @ "bigphoto.png"]; [Cell ad sbueview: bufoto]; } And {cell. Background color = [UIColor blackColor]; Cell.myphoto.image = [UIImage imageNamed: @ "myphoto.png"]; Cell.phototime.text = @ "2014-03-01"; } Return cell; } - (CGFloat) Table view: (UITableView *) Table view height forRowAtIndexPath: (NSIndexPath *) indexPath {if (indexPath.row == 0) {return 320; } 220 returns; }  

I want that the first cell (indexPath.row = 0) is different from the other, the first cell is set to have a big photo and its background color is red (its UI design ), Myphoto.png with the other black background (with the UI deggig of extended cl), but the code runs with the wrong result,

the first cell (indexPath.row = 0) is correct But index Line = 3 or 6 or 9. Similar to indexPath.o = 0, such as indexPath.OR = 1 or 2 or 4 ...

So how can I fix this? Thank you

The cell is being reused, you have to separate the cells Cell identifiers should be used. This should work:

  - (UITableViewCell *) TableView: (UITableView *) Table View CellForouaitindPath: (NSIndexPath *) Indexed Pathith {NSString * CellIdentifier; DetailCell * cell = zero; If (indexPath.row == 0) {cellIdentifier = @ "cell 0"; Cell = [Tableviews Deevar Reusable Cell Ident Identifier: Cell Identifier]; If (cell == blue) {cell = [[extension alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier]; Cell.backgroundColor = [UIColor redColor]; UIImageView * bigphoto = [[UIImageView alloc] initWithFrame: CGRectMake (0, 0, 320, 320)]; Bighatag = 1; [Cell ad sbueview: bufoto]; } UIImageView * bigphoto = (UIImageView *) [cell viewDesign: 1]; Bigphoto.image = [UIImage imageNamed: @ "bigphoto.png"]; } Else {cellIdentifier = @ "Cell 1"; Cell = [Tableviews Deevar Reusable Cell Ident Identifier: Cell Identifier]; If (cell == blue) {cell = [[extension alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier]; Cell.backgroundColor = [UIColor blackColor]; } Cell.myphoto.image = [UIImage imageNamed: @ "myphoto.png"]; Cell.phototime.text = @ "2014-03-01"; } Return cell; }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -