Thursday, December 26, 2013

Rookie consult cell design issues

cell into two columns show, the first column is titlelabel, the second column is the two columns multiline detaillabel (the number of rows label according to the number stored in array fixed)
textvalue is a nsstring: item name, the number of claims; calculators, 0;
The last show is always multi-display () in titlelabel in: (a pair of brackets plus a colon), I do not know why, heroes guidance, thank you very much.


UILabel * titleLabel = (UILabel *) [cell.contentView viewWithTag: kTagTitleLabel];
titleLabel.text = @ "Item Details";
if (textValue! = nil) {

NSUInteger textLength = [textValue length];


while ([textValue length]! = 0) {

NSMutableDictionary * textDic = [[NSMutableDictionary alloc] initWithCapacity: 10];


. NSInteger locoal = [textValue rangeOfString: @ ","] location;
NSString * name = [textValue substringToIndex: locoal];
[TextDic setObject: name forKey: @ "name"];


NSString * temp = [textValue substringFromIndex: locoal +1];
textValue = temp;
textLength = [textValue length];
locoal =. [textValue rangeOfString: @ ";"] location;
NSString * value = [textValue substringToIndex: locoal];
[TextDic setObject: value forKey: @ "value"];

temp = [textValue substringFromIndex: locoal +1];
textValue = temp;

NSLog (@ "textvalue length =% d", [textValue length]);

[TextArray addObject: textDic];
[TextDic release];


}

for (NSUInteger i = 0; i <[textArray count]; i + +) {

NSMutableDictionary * dic = [[NSMutableDictionary alloc] initWithCapacity: 10];
/ / Get value from text array
dic = [textArray objectAtIndex: i];
NSString * name = [dic objectForKey: @ "name"];
NSString * value = [dic objectForKey: @ "value"];

UILabel * detailLabel1 = (UILabel *) [cell.contentView viewWithTag: (kTagLastRowLineView + (i * 2 +1))];
UILabel * detailLabel2 = (UILabel *) [cell.contentView viewWithTag: (kTagLastRowLineView + (i * 2 +2))];

detailLabel1.text = name;
detailLabel2.text = value;

}

}
Reply:
. NSInteger locoal = [textValue rangeOfString: @ ","] location;
NSString * name = [textValue substringToIndex: locoal];
[TextDic setObject: name forKey: @ "name"];


NSString * temp = [textValue substringFromIndex: locoal +1];
textValue = temp;
textLength = [textValue length];
locoal =. [textValue rangeOfString: @ ";"] location;
NSString * value = [textValue substringToIndex: locoal];
[TextDic setObject: value forKey: @ "value"];


Click here to print

No comments:

Post a Comment