ios - 以编程方式定位 UITableViewCell 的内容时使用什么代替 UITextAlignmentRight
<p><p>在苹果自己的文档中,</p>
<p> <a href="https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html" rel="noreferrer noopener nofollow">https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html</a> </p>
<p>它建议在该页面的以下代码段中使用 UITextAlignmentRight:</p>
<pre><code>Listing 5-7Adding subviews to a cell’s content view
#define MAINLABEL_TAG 1
#define SECONDLABEL_TAG 2
#define PHOTO_TAG 3
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ImageOnRightCell";
UILabel *mainLabel, *secondLabel;
UIImageView *photo;
UITableViewCell *cell = ;
if (cell == nil) {
cell = [ initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
mainLabel = [ initWithFrame:CGRectMake(0.0, 0.0, 220.0, 15.0)];
mainLabel.tag = MAINLABEL_TAG;
mainLabel.font = ;
mainLabel.textAlignment = UITextAlignmentRight;
mainLabel.textColor = ;
mainLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
;
secondLabel = [ initWithFrame:CGRectMake(0.0, 20.0, 220.0, 25.0)];
secondLabel.tag = SECONDLABEL_TAG;
secondLabel.font = ;
secondLabel.textAlignment = UITextAlignmentRight;
secondLabel.textColor = ;
secondLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
;
photo = [ initWithFrame:CGRectMake(225.0, 0.0, 80.0, 45.0)];
photo.tag = PHOTO_TAG;
photo.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
;
} else {
mainLabel = (UILabel *);
secondLabel = (UILabel *);
photo = (UIImageView *);
}
NSDictionary *aDict = ;
mainLabel.text = ;
secondLabel.text = ;
NSString *imagePath = [ pathForResource: ofType:@"png"];
UIImage *theImage = ;
photo.image = theImage;
return cell;
}
</code></pre>
<p>但是,Xcode 7 表示 UITextAlignmentRight 自 iOS 6.0 以来已被弃用。然而,Xcode 并没有说明用什么来代替它。请推荐使用什么来代替 UITextAlignmentRight</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你可以使用:NSTextAlignment</p>
<pre><code>label.textAlignment = NSTextAlignmentRight
</code></pre></p>
<p style="font-size: 20px;">关于ios - 以编程方式定位 UITableViewCell 的内容时使用什么代替 UITextAlignmentRight,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/32979412/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/32979412/
</a>
</p>
页:
[1]