UA-17470720-3

Jump to content


Photo
- - - - -

Autoresize SCCustomCell doesn't work for me


  • Please log in to reply
5 replies to this topic

#1 Brendan Duddridge

Brendan Duddridge

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 170 posts
Reputation: 7
Good

Posted 27 January 2016 - 02:14 AM

Hi,

 

I've got a custom cell with a UILabel on top and a UITextView down below. 

 

Using auto-layout I've got everything hooked up such that the edges of both objects are bound to the superview and the top label's bottom is bound to the UITextView's top.

 

I've also tried setting autoResize to YES on my SCCustomCell instance. Doesn't seem to make a difference.

 

I've also tried setting no explicit height on either objects and also explicit heights on each object. I also tried a >= height on both objects too.

 

I can get the UILabel to wrap, but not the UITextView. There's obviously no setting for numberOfLines, nor lineBreakMode on a UITextView, so I'm wondering what I'm doing wrong here.

 

It's a pretty straight forward cell.

 

Any ideas would be greatly appreciated. I have scoured the forum and tried some things that I've ready here.

 

I just need both the label and value to resize vertically.

 

I've tried it with a SCTextViewCell, but I can't get the label to wrap around. I got the value to wrap around though. And the cell resizes as you type which is cool.

 

 

I'm using STV 5.2.1.

Attached Files


Edited by Brendan Duddridge, 27 January 2016 - 02:40 AM.


#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 27 January 2016 - 03:47 AM

Hi Brendan,

 

Does you cell implementation work correctly in a non-STV table view? Setting up dynamically resizing UITextView (as the user types) is incredibly tricky and I am guessing it's not an STV issue.



#3 Brendan Duddridge

Brendan Duddridge

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 170 posts
Reputation: 7
Good

Posted 27 January 2016 - 12:34 PM

Hi Tarek,

 

I have not tried it with a non-STV scenario. In my previous implementation I was going to a different screen to edit the values when you tapped on a cell, so my cells only contained UILabels and that resized properly for me with auto-layout.

 

I thought I'd give STV a try for this particular screen so that users didn't have to visit a different screen to edit the data.

 

So the SCTextViewCell is almost perfect except that the label doesn't wrap, despite telling it to.

 

Thanks,

 

Brendan



#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 27 January 2016 - 01:11 PM

Yes, SCTextViewCell bypasses Auto Layout in order to be able to provide its own dynamic autoresize while the user is typing. You could subclass SCTextViewCell and override its 'getHeight' method, returning [super getHeight] plus an additional label height value that you'll have to manually calculate. I wish there could be a way were we'd both use Auto Layout and provide dynamic autoresizing, but I am not aware of any way to do that.


Edited by Tarek, 27 January 2016 - 02:08 PM.
fixed typo


#5 Brendan Duddridge

Brendan Duddridge

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 170 posts
Reputation: 7
Good

Posted 27 January 2016 - 02:06 PM

Ok, I'll give that a try. And by subclassing SCTableViewCell, I'm assuming you meant SCTextViewCell?



#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 27 January 2016 - 02:08 PM

Oh yes, I apologize for that, just fixed it.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users