Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8078681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:52:25+00:00 2026-06-05T15:52:25+00:00

I am subclassing UITextView, and i got it working, but i also want to

  • 0

I am subclassing UITextView, and i got it working, but i also want to do some extra work when the UITextView Delegate methods are called. here is what i have so far.

ThanaaTextView.h

#import <UIKit/UIKit.h>

#import "ThaanaDelegate.h"


@interface ThaanaTextView : UITextView  {

    @private
    ThaanaDelegate * _thaanaDelegate;

}

ThanaaTextView.m

#import "ThaanaTextView.h"


@implementation ThaanaTextView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
       //do some extra stuff to textview
       //set delegate
       self.delegate = _thaanaDelegate;



    }
    return self;
}


}

@end

and here is my delegate class

ThaanaDelegate.h

 #import <UIKit/UIKit.h>
 #import <Foundation/Foundation.h>


@interface ThaanaDelegate : NSObject <UITextViewDelegate> {

    NSMutableArray* _lines;
}

   +(NSString*) reverseText:(NSString*) text withFont:(UIFont*) font carretPosition:(NSRange*) cpos Lines:(NSMutableArray*) lines Bounds:(CGRect) bounds;
-(void) setText:(NSString*) txt textview:(UITextView *)textView;


@end

ThaanaDelegate.m

 -(BOOL) textView:(UITextView*) textView shouldChangeTextInRange:(NSRange) range replacementText:(NSString*) text {
    //delegate method i want to do things in

    return NO;
}



-(void) setText:(NSString*) txt textview:(UITextView *)textView {

    //stuff
    return txt;
}

it compiles and runs without errors. but the delegate functions are never called. what am I’m missing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:52:26+00:00Added an answer on June 5, 2026 at 3:52 pm

    When you init the ThanaTextView, the delegate is not yet set.

    self.delegate = _thaanaDelegate;
    

    _thaanaDelegate is nil at this point. Ergo, you are setting it to nil.

    Edit:

    ThaanaTextView *ttv = [[ThaanaTextView alloc] initWithFrame:textViewFrame];
    ttv.delegate = someDelegateHere;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im doing a test for subclassing uiControl, but it is not working yet, here
I want to display texts in UITextView with different colors and underline some of
I have a scrollable, non-ediable UITextView. I want to add a gesture recognizer to
I have a UITableViewController and a MyTableViewCell subclassing UITableViewCell . I want to inform
If I have a custom class subclassing Sprite and it draws some simple objects,
I am subclassing a UIGestureRecogniser, but for some reason the method - (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer{
I'm subclassing UITableViewCell to have one image on the far left, then some text
I have a question regarding Subclassing and Class methods. I have a base class
I'm contemplating subclassing UIScrollView (the way UITextView does) to draw a fairly large amount
Question about subclassing in matlab, under the new class system. I've got class A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.