相关疑难解决方法(0)

根据文字调整UILabel高度

考虑我在UILabel(动态文本的长行)中有以下文本:

由于外星军队的数量远远超过了团队,因此玩家必须利用后世界末日的世界,例如在垃圾箱,支柱,汽车,瓦砾和其他物体后面寻找掩护.

我想调整UILabel's高度,以便文本可以适应.我正在使用以下属性UILabel来使文本包装.

myUILabel.lineBreakMode = UILineBreakModeWordWrap;
myUILabel.numberOfLines = 0;
Run Code Online (Sandbox Code Playgroud)

如果我没有朝着正确的方向前进,请告诉我.谢谢.

cocoa-touch uikit uilabel ios

310
推荐指数
12
解决办法
26万
查看次数

如何检查UILabel是否被截断?

我有一个UILabel依赖于我的应用程序是否被纵向或横向模式下运行在iPhone或iPad,可以长短不一.当文本太长而无法在一行显示并且它被截断时,我希望用户能够按下它并获得全文的弹出窗口.

如何查看是否UILabel截断文本?它甚至可能吗?现在我只是根据我所处的模式检查不同长度,但它不能很好地工作.

iphone truncate objective-c uilabel ios

97
推荐指数
9
解决办法
5万
查看次数

不推荐使用UILineBreakModeWordWrap

这是我的代码:

CGSize s = [string sizeWithFont:[UIFont systemFontOfSize:20]
               constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, CGFLOAT_MAX) // - 40 For cell padding
                   lineBreakMode:UILineBreakModeWordWrap];
Run Code Online (Sandbox Code Playgroud)

我收到一条警告,在iOS 6中不推荐使用UILinebBreakModeWordWrap.

deprecated uilabel

82
推荐指数
2
解决办法
5万
查看次数

我如何获得 - [NSString sizeWithFont:forWidth:lineBreakMode:]工作?

我更新了我的问题" 调整UILabel(在iPhone SDK中)以适应? ",并在建议的解决方案中描述了我的问题,但没有得到答案.也许我会通过提出一个新问题来获得更好的结果......

我在以下代码后设置了一个断点:

NSString *theText = @"When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
CGSize …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch

21
推荐指数
2
解决办法
4万
查看次数

iPhone UILabel sizeWithFont:

我正在尝试测量NSString的视觉大小,该大小考虑了我可以渲染的行数.但是,sizeWithFont没有考虑numberOfLines属性?因此,我的布局算法将所有内容都置于低于实际需要的位置.

_price = [[UILabel alloc] init];
_price.text = myPriceValue;
_price.lineBreakMode = UILineBreakModeWordWrap;
_price.numberOfLines = 3;
_price.backgroundColor = [UIColor clearColor];
_price.textColor = TTSTYLEVAR(colorPrice);
/// the follow code ignores numberOfLines and just tells me the size of the whole block.  
// I'd like it to be aware of numberOfLines
//
CGSize priceSize = [_price.text sizeWithFont:_price.font
        constrainedToSize:CGSizeMake(maxWidth, CGFLOAT_MAX)
        lineBreakMode:UILineBreakModeWordWrap];
Run Code Online (Sandbox Code Playgroud)

有谁知道如何使用iPhone SDK做到这一点?

iphone fonts objective-c uilabel

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

uilabel ×4

cocoa-touch ×2

ios ×2

iphone ×2

objective-c ×2

deprecated ×1

fonts ×1

truncate ×1

uikit ×1