I'm sure this is very easy but I can not find any documents about it ..
I have text labels right in my utiwhite (my app is in hebrew, which is RTL) I am trying to add an image to the right of the text label in the cell, no luck, so far this image is on the left side Coalition and I can not find any way to align it on the right side of the cell The breakfast.
Here is my code:
- (UITableViewCell *) tableView: (UITableView *) Table view cellforoutoundpath: (NSIC xpath *) IndexPath {static NSSTING * cell identifier = "cell "; UITableViewCell * cell = [tableview] dequeueReusableCellWithIdentifier: CellIdentifier]; If (cell == zero) {cell = [[[UITableViewCell alloc] initWithFrame: CGRectZero reuseIdentifier: CellIdentifier] autorelease]; } Cell.imageView.image = [UIImage imageNamed: @ "tableicon.png"]; NSString * cellValue = [[Stories ObjectAutandex: IndexPath.ro] ObjectForreake: @ "ArticleTitle"]; Cell.textLabel.text = cellValue; Cell.textLabel.textAlignment = UITextAlignmentRight; Cell.textLabel.font = [UIFont systemFontOfSize: 17]; Cell.textLabel.numberOfLines = 2; Return cell; } - (CGFloat) Table view: (UITableView *) Table view height forRowAtIndexPath: (NSIndexPath *) indexPath {return 50; }
Instead of adding the image as a subview of your UITableViewCell, add a container Right aligned subviews UIImageView * pic = myImageView; UIView * picContainer = [[UIView alloc] initWithFrame: cell.frame]; PicContainer.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; PicContainer.contentMode = UIViewContentModeRight; Pic.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; Pic.center = CP pointmake (picContainer.frame.size.width-70, picContainer.frame.size.height / 2); [PicContainer addSubview: pic]; [Cell.contentView addSubview: picContainer]; This occurs when the orientation changes, there is an added advantage of automatically readjusting.
Comments
Post a Comment