iOS UIButton文本未被截断
我正在制作一个从数据生成UITableView的应用程序。我有一个自定义UITableViewCell,其中包含一个带有文本的UIButton。其中一个生成的按钮的标题对于UIButton来说太长,但是没有像我在UIStoryBoard中选择的那样被截断。这些单元格是在my UITableViewController函数中创建的iOS UIButton文本未被截断,ios,ipad,uibutton,uistoryboard,truncate,Ios,Ipad,Uibutton,Uistoryboard,Truncate,我正在制作一个从数据生成UITableView的应用程序。我有一个自定义UITableViewCell,其中包含一个带有文本的UIButton。其中一个生成的按钮的标题对于UIButton来说太长,但是没有像我在UIStoryBoard中选择的那样被截断。这些单元格是在my UITableViewController函数中创建的 -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(nsindepa
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(nsindepath*)indepath
与原型单元格一样正常
我无法添加图像,因为我是新用户,但这里有几个图像链接:
UIStoryBoard设置:
标题位于UIButton的边界之外:
有人知道如何解决这个问题吗。它早就开始工作了。我更改了UIButton的大小和标题文本的字体,但我认为这不会有什么区别
下面是我在-(UITableViewCell*)tableView:(UITableView*)tableView单元格中设置按钮文本的代码,用于rowatindexpath:(nsindepath*)indepath
CellIdentifier = @"PopoverCell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
((MSPopoverCell *)cell).nameLabel.text = data.FullName; //setting the label, works fine
[((MSPopoverCell *)cell).button setTitle:data.DisplayString forState:UIControlStateNormal];//setting the button title, bleeds over
另外,我是stackoverflow的新手,所以如果我遗漏了应该包括的内容,请给我一些友好的建议。
谢谢
Max我还尝试通过编程方式将UIButton的LineBreakMode设置为NSLineBreakByTruncingTail,但没有成功。奇怪。将文本对齐方式设置为“左”可以修复出血,但这不是我想要的…您可以编辑您的问题以显示如何设置该单元格按钮文本标题的代码吗?