Welcome, Guest
Username Password: Remember me

TOPIC: Custom UITextView

Custom UITextView 1 year, 7 months ago #1

Hi,

I just wanted to see if its possible to use and initialise my own custom UITextView in the Sensible framework. In willDisplayCell:(SCTableViewCell *)cell I have some custom code like :


if([cell isKindOfClass:[SCTextViewCell class]]) {
SCTextViewCell *textViewCell = [SCTextViewCell alloc] init];
textViewCell = (SCTextViewCell *)cell; // UITextView
}

but I want to be able to further and use say :
textViewCell.textView = [InspectionTextView alloc] init];

where InspectionTextView subclasses UITextView since I need to override the canPerformAction and becomeFirstResponder methods etc.

Is this possible ?? at the moment since textViewCell.textView is a readonly property it wont allow me.
  • monsta
  • OFFLINE
  • Expert Boarder
  • Posts: 130
  • Karma: 2

Re: Custom UITextView 1 year, 7 months ago #2

Hi Phil,

You must subclass SCTextViewCell in order to achieve this. SCTextViewCell conforms to the UITextViewDelegate, so you can easily handle the events you want (please don't forget to call the super class methods as SCTextViewCell uses some of these delegate methods itself). Please tell me if you need any further help with subclassing SCTextViewCell.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Custom UITextView 1 year, 7 months ago #3

Hi Tarek,

Ok thanks. Yeah some help would be good. So would I still use the following code to initialize the new subclass :

if([cell isKindOfClass:[SCTextViewCell class]]) {
CustomSCTextViewCell *textViewCell = [CustomSCTextViewCell alloc] init];
textViewCell = (CustomSCTextViewCell *)cell; // UITextView
}

but then in the subclass which methods should I implement and then call the super on ? Would the interface be something like ?
@interface CustomSCTextViewCell : SCTextViewCell <UITextViewDelegate> { }

Thanks.

PS. The new v1.6 is awesome. Its great that you have the iPad support in it as well.
  • monsta
  • OFFLINE
  • Expert Boarder
  • Posts: 130
  • Karma: 2

Re: Custom UITextView 1 year, 7 months ago #4

Hi again Phil,

I can just create a SCTextViewCell subclass template for you to work with, this should make your life a lot easier. I have one question though: are you having a class definition that automatically generates the cells for you, or will you be creating the new subclassed cell manually?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Custom UITextView 1 year, 7 months ago #5

Cool thanks. At this stage the class definition will be automatically creating the cells.

Edit. Actually I may need both since I will be creating the subclass cell manually next week sometime for another a sub view.
  • monsta
  • OFFLINE
  • Expert Boarder
  • Posts: 130
  • Karma: 2
Last Edit: 1 year, 7 months ago by monsta.

Re: Custom UITextView 1 year, 7 months ago #6

Hi All,

If the template could be posted to the forum (or if you could email it across to me as well) that would be great, as I am trying to do exactly the same thing as Phil so this would be really useful for me.

Thanks,
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2
Time to create page: 1.02 seconds