Rich text editor for web browsing for iPhone

I need to create a text editor (to align text, fonts, bold, italics, underline, etc.) for an iPhone application. I heard about storing data in HTML format and rendering it in a UIWebView. I want to allow the user to edit the data, and in my application I use TapDetectingWindow to detect strokes in the UIWebView (exactly the same detail here ).

- (id)init { self = [super init]; if (self) { tapDetectingWindow = (TapDetectingWindow *)[[UIApplication sharedApplication].windows objectAtIndex:0]; //mWindow, variable reference to TapDetectingWindow tapDetectingWindow.viewToObserve = webView; tapDetectingWindow.controllerThatObserves = self; webView = [[UIWebView alloc] init]; [webView setFrame:CGRectMake(0, 0, 340, 1900)]; [webView setTag:1]; [webView addSubview:keyboardText]; [webView setDelegate:self]; [webView setOpaque:0.0]; [webView loadHTMLString:htmlString baseURL:NULL]; [self.view addSubview:webView]; keyboardText = [[UITextField alloc] init]; keyboardText.autocorrectionType = UITextAutocorrectionTypeNo; [keyboardText setDelegate:self]; [self.view addSubview:keyboardText]; } return self; } 

But my application crashes with a message

 tapDetectingWindow.viewToObserve = webView 

and report

 * -[UIWindow setViewToObserve:]: unrecognized selector sent to instance 0x4a26b90 
+4
source share
1 answer

After hours of hair pulling, here is the answer: you need to edit the AppDelegate.m file to make TapDetectingWindow work correctly:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIViewController* vc = self.window.rootViewController; self.window = [[TapDetectingWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = vc; return YES; } 

I tried this and it works great with the rest of the TapDetectingWindow tutorial.

+3
source

Source: https://habr.com/ru/post/1393748/


All Articles