This title to get a little confused, do not know can cause heroes attention!
Is this, I have some data, using JSON to save, and then read the dictionary. Print out the data dictionary as follows:
{ScoreDoc = ({"id" = 1, "shop_id" = 3579, "city_id" = 3, shop_name = "NIKE", image = "nike.jpg", shoptitle = "welcome to NIKE", ......}, < br />{"Id" = 2, "shop_id" = 4673, "city_id" = 3, shop_name = "ANTA", image = "anta.jpg", shoptitle = "welcome ti ANTA", ......},
{......},
{......},);
totalHits = 5000;
useSecond = "0.006";}
I define a tableview, defines a tableviewcell, cell controls a UIImageView, two TextLabel, I want the first line to the left of the display NIKE tableview a picture, label the top right of the display shop_name, below the right The label displayed shoptitle, on the left side of the second line of the display ANTA tableview a picture, on the right top of the label display shop_name, label the bottom right of the display shoptitle, and so on.
To achieve this effect, how can I do? First, I definitely want to traverse the dictionary, how to traverse it? Then how should I do to the corresponding content is displayed in the corresponding tableview row? Thank you!
Reply:
The dictionary conversion subscript array, the array corresponds to a row tableview
Reply:
How this transformation? Give an example? Thank you!
Reply:
NSDictionary method allValues returns an array of all the values
There may also need to do some sort array processing
Reply:
The delegate for the table and the array is not enough understanding
Each cell of the data sources [array objectatindex: row] to
Reply:
You're right, since the beginning of school, so my first contact, whether it is tableview or NSdictionary, now or have not got a clue.
Reply:
I want to show a different picture on each cell in
cell.imageView.image = [UIImage imageNamed: [data objectAtIndex: [indexPath row]] objectForKey: @ "coupon_s_image"];
Such use is wrong?
Also, I have two textLabel, use the tag to control the display, but does not work,
if (cell.textLabel.tag == 1) {
cell.textLabel.text = [[data objectAtIndex: [indexPath row]] objectForKey: @ "shop_name"];
}
if (cell.textLabel.tag == 2) {
cell.textLabel.text = [[data objectAtIndex: [indexPath row]] objectForKey: @ "coupon_title"];
}
In this case, cell no content. This should be how to write? Please Weapon heroes! ! ! Thank you!
Reply:
1 In the viewDidLoad method controller Gaga json data contained in, and get NSDictionary object
2.
In UITableView's delegate method
- (UITableViewCell *) tableView: (UITableView *) tableView
cellForRowAtIndexPath: (NSIndexPath *) indexPath {
NSUInteger row = [indexPath row];
NSDictionary * mydict = [dict objectForKey: @ "ScoreDoc"];
UITableViewCell * cell = nil;
......
......
cell.textLabel.text = [mydict objectForKey: @ "shop_name"];
....
return cell;
}
Reply:
Thank you two brother's instructions, and now it is a frame size is not set!
Reply:
You're right, since the beginning of school, so my first contact, whether it is tableview or NSdictionary, now or have not got a clue.
No comments:
Post a Comment