UITableViewCell Align all subviews
I have a custom UITableViewCell
which has some subviews. i.e. some labels, some images. I want all these subviews to be right aligned in the UITable. How do i do that?
I have tried these approaches -
1.In InterfaceBuilder when I select the UITableViewCell, I can set the "indentaion" section. It's by default 0, I made it 100 but I see no change in the device.
2.I have tried this in the code too. Override the default method...
(NSInteger)tableView:(UITableView *)tableView
indentationLevelForR开发者_Go百科owAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
The above code also does not work. How do I align all my subviews in my UITableViewCell
to right?
Basically, I want to display one cell left aligned (which is default) & some cells right aligned. As shown in the picture.
There is automatic way everything will align to right. You will have to lay the view appropriately. For UITextField
and UILabel
objects you can set the textAlignment
property to UITextAlignmentRight
.
label.textAlignment = UITextAlignmentRight;
If necessary you must also adjust the autoresizingMask
of the views to set it such that it has a UIViewAutoresizingFlexibleLeftMargin
mask set so that they stick to the right on view resize.
use interface builder for alignment.
精彩评论