Wednesday, December 25, 2013

Custom tableview

I was in a cell inside tableview added a label and button, I want to achieve what I clicked on the button above you can find the value of the corresponding label, so I add! if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault
reuseIdentifier: SimpleTableIdentifier] autorelease];


UIButton * button = [UIButton buttonWithType: UIButtonTypeCustom];
[Button setFrame: CGRectMake (288, 10, 29, 29)];
[Button setImage: [UIImage imageNamed: @ "Unselected.png"] forState: UIControlStateNormal];
[Button addTarget: self action: @ selector (imageButt :)
forControlEvents: UIControlEventTouchUpInside];
/ / [Button setTag: (int *) row];
[Cell.contentView addSubview: button];
/ / [Button release];

UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake (10, 10, 280, 30)];
[Label setBackgroundColor: [UIColor clearColor]];
[Label setTextColor: [UIColor whiteColor]];
[Label setTag: 1];
[Cell.contentView addSubview: label];
[Label release];
}
UILabel * textName = (UILabel *) [cell.contentView viewWithTag: 1];
[TextName setText: [array objectAtIndex: row]];

Tried to use tag, but with the bad, or there would appear to solve this kind of approach, the impatient, thank you! !
Reply:
That is not called custom
Should inherit UITableViewCell, then rewrite the contents inside, the definition of the height delegate
Reply:
I re-customize it again, but to achieve the desired effect, but the picture is always automatically change! ! Click the button because I will transform the image to show clicked, and then when I click on a drop-down, click on the button below the picture and some do not also become

Reply:
Top handle, hurry! Click on a button dropdown always behind when it becomes always a button after clicking the picture, but I looked at the print out, it just changed the picture, it did not click too! ! Should overlap problem, there will be a solution or encountered under, thank you!
Reply:
I was in a cell plus button, then click on the picture will become, I tableview per page 5 data, I clicked on the button to change after the first, then drop down, after every 5 every cell would have to change his image, there is the case of or would help to solve the next! !
Reply:
Engage in object-oriented, looking at your code should be very hard to accept, uh. Upstairs say, should put your cell implementations inherit UITableViewCell into the class. A cell, an instance of your inherited class. Doing so would like you said the problem appeared immune to, uh.

No comments:

Post a Comment