Showing posts with label interface. Show all posts
Showing posts with label interface. Show all posts

Sunday, November 21, 2010

How to Disable Copy, Paste and Select for UITextView

Need to use UITextView, but don't want Copy, Paste and Select feature. How to disable that? Tried overwriting canPerformAction:withSender but I got still a flash of quickly disappearing popup menu and selection.

Subclass UITextView and overwrite canBeforeFirstResponder to return always NO:
@interface MyUITextView : UITextView
@end
@implementation MyUITextView
- (BOOL)canBecomeFirstResponder
{
   return NO;
}
@end
Now you have completely hidden and disabled copy, paste and select for UITextView!

Thursday, July 1, 2010

Class does not implement the 'NSStreamDelegate' protocol

Got this warning after upgrading to Xcode 3.2.3. To fix it add NSStreamDelegate into your class interface:
@interface MyClass: NSObject {}
@interface MyClass: NSObject <NSStreamDelegate> {}
NSStreamDelegate is defined for Cocoa, but not Cocoa Touch. iPhone stream:handleEvent: is an informal delegate method.

On Mac OS X 10.6 SDK (used by iPhone OS 4) delegate methods are generally defined in formal protocols rather than informal protocols as before, which means you have to declare the protocol conformance in the class interface of the delegate. More info at Mac OS X SDK release notes.