Objective-C使用AutoResizingMask在UitableViewCell内部将UILabe对齐 [英] objective-c Align UILabe to right inside UitableViewCell using AutoResizingMask

查看:85
本文介绍了Objective-C使用AutoResizingMask在UitableViewCell内部将UILabe对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个iPhone应用程序,现在我正在尝试使用自动调整大小蒙版将自定义tableview单元内的uilabel对齐到右侧,我正在界面生成器中进行此操作,并且正在使用情节提要,但是我遇到的问题是是当我在iphone 6模拟器中运行应用程序时标签只是消失了,当我将标签对齐到表格视图单元格的左侧时,自动调整大小功能正常,但是奇怪的是,当我尝试将标签对齐到表格视图单元格的右边时,自动调整功能不起作用,我该怎么做?

I am creating an iPhone app, now i am trying to align a uilabel inside custom tableview cell to the right using autoresizing mask, i am doing it in interface builder and i am using storyboards, but the problem i am having is that the label just disappears when i run app in iphone 6 simulator, the autoresizing is working fine when i align label to the left of table view cell, but strangely it is not working when i try to align the label right of table view cell, how should i do this?

注意:我不需要将uilabel文本对齐,但是需要将uilabel本身对齐到右边.

Note: i don't need to align the uilabel text but need to align the uilabel itself to right.

推荐答案

答案用于我的项目,请根据需要自定义x,y,宽度和高度

the answer is used for my project , please customize the x, y , width and height as you need

我也遇到同样的问题,所以我遵循这种方法cellForRowAtIndexPath

I also face the same problem , SO i follow this method cellForRowAtIndexPath

cell.yourlableName.frame=CGRectMake(add your label x - position,add your label Y position, [[UIScreen mainScreen] bounds].size.width- add your label width, add your label Height ); for example in your iPhone 4 width is 320 so reduce the width 320-yourlabel width, 

其他部分在您的自定义单元格类中调用此行

else part call this line in your custom cell class

- (void)awakeFromNib {

     cell.yourlableName.frame=CGRectMake(180.0f,220.0f, [[UIScreen mainScreen] bounds].size.width-216.0f, 19.0f); 

   }

在所有显示在右侧的设备中,它对我来说都能正常工作.

its working fine for me in all device it shows in right side perfectly.

这篇关于Objective-C使用AutoResizingMask在UitableViewCell内部将UILabe对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆