I'll show you my problem by image. I have tableView in which i customize the UITableViewCell and tableViewCell having UILabel field. In this UILabel field data is coming by parsing the XML file data come completely but a little alignment problem it looks like a paragraph showing in image given below:-
and this in my code which is used to print data on this UItableViewCell's UILabel:-
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIn开发者_开发知识库dexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableCell13" owner:self options:NULL];
cell = nibLoadedCell;
}
titleLabel.text = aNewsInfo.title;
return cell; }
and I used Interface Builder (IB) for designing the cell i showing the setting by the image given blow for the UITableView cells UILabel :-
any one suggest me the method how can i rectify this problem.
Thanks in advance
Does the UILabel display the indentation when you set the text via IB? If not, I suspect that your parsed text has a space at the beginning. Try using:
titleLabel.text = [aNewsInfo.title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
And if that works, put this in your parser for all strings found for each tag.
It seems that one or two space coming from your server xml file. Did you check string you are getting from xml have spaces or not ?
精彩评论