iphone - UITableViewCell. How do I programmatically align textLabel to top? -
By default, a UITableViewCell instance is located in the textLabel / detailTextLabel labeled pair in the center of its original view. I like the combination of a cell at the top of the cell. How can I do that program?
Thanks, Doug
Description of docs - [UIView layoutSubviews]
"Layouts are overridden by subclasses in subviews when influencing is implemented. The default implementation of this method is nothing."
This description is not elaborate, but correct in this situation, the behavior of the method is to layout your subviews, this device will ever apply to orientation changes. Whenever you call call-set NADE layout, it is also later set for the invitation.
Because implementation of UIView does not do anything (and I guess it for UI control), you will have full creative freedom to prepare sub-views of your UVV sub-class
- Override - layout touch and
- to manipulate the position:
The built-in text label and the --DoubleLabel view.
- Override -viewDidload,
- Create two UILabels to provide text and detailed text, <
- to manipulate the position:
- To manipulate the status of your custom UILB views
- Override - P> One, to avoid the recommendation # 1, the underlying text label and Adding Extension TextLabel
A more reliable condition would be to do this:
@Inteface Metabivusel: UITableViewCell {U iLabel * myTextLabel; UILabel * myDetailTextLabel; } // ... Property Announcements @end @implementation MyTableViewCell @ myTextLabel Synchronize, myDetailTextLabel; - (id) initWithFrame: (CGRect) frame {self = [super initWithFrame: frame]; If (self) {myTextLabel = [[[UILBL Alloc] InitVithframe: CGRxSiro] AutoEques]; [Self.contentView addSubview: myTextLabel]; MyDetailTextLabel = [[[UILabel alloc] initWithFrame: CGRectZero] AutoExecution]; [Self.contentView addSubview: myDetailTextLabel]; } Healthy return; } - (zero) Delok {[myTextLabel release]; [MyDetailTextLabel release]; [Super DeLoc]; } - (zero) layouts SUBEView {// Super Class UITableViewCell should do whatever layout should. // Just do not use the built-in text label or descriptionTableLabel properties [super layoutview]; // Now layout your custom ideas / size to adjust labels to your text [myTextLabel sizeToFit]; [MyDetailTextLabel Size Tofit]; // Label the top of the table cell, CGRect newFrame = myTextLabel.frame; NewFrame.origin.x = CGRectGetMinX (self.contentView.bounds); NewFrame.origin.y = CGRactGatMani (auto.citentview.bound); [MyTextLabel setFrame: newFrame]; // Expand the text label immediately to the correct / w / 10 pixel difference between them; NewFrame = myDetailTextLabel.frame; NewFrame.origin.x = CGRectGetMaxX (myTextLabel.frame) + 10.; NewFrame.origin.y = CGRactGatMani (auto.citentview.bound); [MyDetailTextLabel setFrame: newFrame]; } @end
In MyTableViewCell, you will ignore the built-in text labels and will use your own custom UILabels to take full control of positioning you within the content reset of the table view cell. .
I am extracting lots of stuff. In custom layout with text labels, you want to consider:
-
find out your own layout algorithm
I have a layout algorithm I'm using a custom UIL AdBlue size to touch the custom text, then keeps them side-by-side. You want something more specific for your app.
-
Containing custom labels in the content view
In-OutoutSweeps, you want the logic of custom UILabels to be deployed and so that they do not fall out of the content rect limit, with my inexperienced layout logic, any of the UILBL (or both) Long text was removed from which the label could be moved out of the content limits.
-
How to handle - viewDidLoad / -viewDidUnload.
As coded above, this subclass is not loaded with a nibb. You would want to use IB to move your cell, and if you do this, you will need to think about the -viewDidLoad / -viewDidUnload / -initWithCoder:
-
Comments
Post a Comment