Rich Text Editor in Table view

Posted by pubudu on Stack Overflow See other posts from Stack Overflow or by pubudu
Published on 2013-10-27T09:50:59Z Indexed on 2013/10/27 9:53 UTC
Read the original article Hit count: 246

Filed under:
|
|

Im try to implement rich text editor in table view cell.

before this i test rich text editor using web view.it work fine

I want to put this web view inside my costume cell.

i did it, but it not working (bold , italic ... styles)

how can i pass stringByEvaluatingJavaScriptFromString:@"document.execCommand(\"Bold\") this command to webview in cell

i did like this

in viewContoller

- (IBAction)clickbold:(id)sender
{
    static NSString *CellIdentifier = @"Cell1";
    Cell *cell = [_tableview dequeueReusableCellWithIdentifier:CellIdentifier];

    cell = [_tableview cellForRowAtIndexPath:0];
    [cell.webView stringByEvaluatingJavaScriptFromString:@"document.execCommand(\"Bold\")"];
    [_tableview beginUpdates];
    [_tableview endUpdates];
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell1";
    Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


    {
        NSBundle *bundle = [NSBundle mainBundle];
        NSURL *indexFileURL = [bundle URLForResource:@"index" withExtension:@"html"];
        [cell.tableview  loadRequest:[NSURLRequest requestWithURL:indexFileURL]];
        cell.webView.delegate = self;
        [cell.webView stringByEvaluatingJavaScriptFromString:@"document.execCommand(\"Italic\")"];

        return cell;
    }

    return cell;
}

my html file like this

<html>
    <head>
        <script>
            function myFunction()
            {
                window.location.href = "myclick://buttonClicked";

            }
            function onKEYPRESS()
            {
                window.location.href = "onkeypress://buttonClicked";
            }
        </script>
    </head>
    <body>
    <body>
        <div id="content" contenteditable="true" style="font-family:Arial" onfocus="myFunction()" onkeypress="onKEYPRESS()">TEXT TEXT
        </div>
    </body>
</html>

© Stack Overflow or respective owner

Related posts about ios

Related posts about uiwebview