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 8283623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:47:53+00:00 2026-06-08T10:47:53+00:00

I am trying to override a method in the uitextview class and i want

  • 0

I am trying to override a method in the uitextview class and i want to do it in the class i am working in but i can’t get it to work. I have only seen people override it in a separate class. Thank You.

   #import <UIKit/UIKit.h>
@interface MyTextView : UITextView

@end
@interface ViewController : UIViewController
@property (nonatomic, retain) IBOutlet MyTextView * tv;

@end





//////////////////////////////////





   #import "ViewController.h"



@implementation MyTextView

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender    
{    
    [UIMenuController sharedMenuController].menuVisible = NO;  //do not display the menu
   // [self resignFirstResponder];                      //do not allow the user to selected anything
    return NO;
}

@end


@implementation ViewController
@synthesize tv;

- (void)viewDidLoad
{
    [super viewDidLoad];
    tv = [[MyTextView alloc] init];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}
-(void)textViewDidChangeSelection:(MyTextView *)textView
{
    NSRange range = textView.selectedRange;
    if(range.location<textView.text.length)
    {
        NSString * getRidOfFirstHalfString = [tv.text substringFromIndex:range.location];
        NSString * selectedString = [getRidOfFirstHalfString substringToIndex:range.length];


        NSLog(@"%@",selectedString);

    }
    else
    {
        // Do what ever you want to do

    }   
}
@end
  • 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-08T10:47:55+00:00Added an answer on June 8, 2026 at 10:47 am

    Put in the top of your class:

    @interface MyTextView : UITextView
    
    @end
    
    @implementation MyTextView
    
    - (xxx)overRidedMethod
    {
        // do something
    }
    
    @end
    
    ... your class
    {
        MyTextView *foo = [MyTextView alloc] init.....]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to override equals method in Java. I have a class People
I am trying to override a parent class method. I successfully done so. But
I need to override onMeasure method but when trying to override I get error:
I have been trying to override the database method of the loader class (CI_Loader).
I'm trying to override a method inside a jquery widget. The method can be
im trying to override the add() but it will not compile public class AVLTree<E
I'm trying to figure out how I can override the auth_views.logout method. Normally I
I am trying to override the load() (abstract) method in org.primefaces.model.LazyDataModel class (from Primefaces
Am trying to override get() method in my view as : broadcast = Broadcast.objects.get(request,
I'm trying to override a method of the base class used by another method

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.