resize UITableViewCell textLabel

I have a UITableViewCell that I would like to add a view to the right (in addition to the accessory view). I tried setting the size of textLabel to be a few pixels narrower but it just resizes it back.

Is there any way to resize textLabel?


The object referenced by the default textLabel property, in UITableViewCell instances of type UITableViewCellStyleDefault, cannot be resized, at least not in my experience. The best idea in these cases is to create your own subclass of UITableViewCell, in code or even with Interface Builder if you want, and give it the layout that you want.

Actually it CAN be resized if you create an UITableViewCell subclass and override the layoutSubviews method:

- (void)layoutSubviews {
[super layoutSubviews];  //The default implementation of the layoutSubviews

CGRect textLabelFrame = self.textLabel.frame;
textLabelFrame.size.width = _textLabelMaxWidth;
self.textLabel.frame = textLabelFrame;

Hope it helps.

Need Your Help

How to verify that the source code is copied from web

security checksum sha code-access-security

I am building a web tool to check whether the submitted content is taken from web or is it submitter own work. A plagiarism detector.

Get child element programmatically selenium c#

c# selenium selenium-webdriver selenium-chromedriver

What I am trying to achieve is to programmatically open the first video on the web page which is enabled and displayed. I am getting the video elements by using Xpath search method and clicking on ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.