Search code examples
iphoneuitextviewsubclassuiactionsheetuiresponder

How to subclass UITextView


How can I subclass UITextView in UIActionSheet to overwrite canBeforeFirstResponder to disable copy, select, and select all in UITextView.

#import <UIKit/UIKit.h>

@class English;

@protocol EnglishDelegate

- (void)dismissViewDidFinish:(UIViewController *)viewController;

@end


@interface English: UIViewController <UITextViewDelegate, UIScrollViewDelegate>


{
id<EnglishDelegate> delegate;
UITextView *textView;
UINavigationBar *navBar;
UINavigationController *navigationController;

}

@property (nonatomic, retain) UITextView *textView;
@property (nonatomic, assign) UINavigationBar *navBar;
@property (strong, nonatomic) UINavigationController *navigationController;
@property (nonatomic, assign) id<EnglishDelegate> delegate;
@property (nonatomic, retain) UIScrollView *scrollView; 

-(void)dismissView:(id)sender;

@end

Anyone knows how to subclass it in h file.

Thanks for help.


Solution

  • You wouldn't subclass UITextView inside of another class; you would just plain subclass it in another file and override the canBecomeFirstResponder as so:

    - (BOOL)canBecomeFirstResponder {
        return NO;
    }