Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZSSToolbarInsertImageFromDevice Custom Order Crash #132

Closed
willptswan opened this issue Jul 14, 2016 · 8 comments
Closed

ZSSToolbarInsertImageFromDevice Custom Order Crash #132

willptswan opened this issue Jul 14, 2016 · 8 comments

Comments

@willptswan
Copy link
Collaborator

When using a custom order with a select few bar button items, if I include ZSSToolbarInsertImageFromDevice I get a crash on:

self.toolbar.items = items; (line 715 in buildToolBar method)

Error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString view]: unrecognized selector sent to instance 0x100228460'

@purplepeng
Copy link

@William205 I have the same problem,what's your solution?Thanks.

@willptswan
Copy link
Collaborator Author

willptswan commented Aug 31, 2016

I managed to fix it by changing a line of code in the ZSSRichTextEditor.m source file.

Try going to the following method:

- (NSArray *)itemsForToolbar

Then find

// Image From Device
if ((_enabledToolbarItems && [_enabledToolbarItems containsObject:ZSSRichTextEditorToolbarInsertImageFromDevice]) || (_enabledToolbarItems && [_enabledToolbarItems containsObject:ZSSRichTextEditorToolbarAll])) {
    ZSSBarButtonItem *insertImageFromDevice = [[ZSSBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ZSSimageDevice.png"] style:UIBarButtonItemStylePlain target:self action:@selector(insertImageFromDevice)];
    insertImageFromDevice.label = @"imageFromDevice";
    if (customOrder) {
        [items replaceObjectAtIndex:[_enabledToolbarItems indexOfObject:ZSSRichTextEditorToolbarInsertImage] withObject:insertImageFromDevice];
    } else {
        [items addObject:insertImageFromDevice];
    }
}

I changed the following line:

[items replaceObjectAtIndex:[_enabledToolbarItems indexOfObject:ZSSRichTextEditorToolbarInsertImage] withObject:insertImageFromDevice];

to:

[items replaceObjectAtIndex:[_enabledToolbarItems indexOfObject:ZSSRichTextEditorToolbarInsertImageFromDevice] withObject:insertImageFromDevice];

After I did that it all worked perfectly.

@nnhubbard
Copy link
Owner

Can you submit a PR for this?

@willptswan
Copy link
Collaborator Author

Pull request submitted

nnhubbard added a commit that referenced this issue Aug 31, 2016
Fixed ZSSToolbarInsertImageFromDevice Custom Order Crash #132
@nnhubbard
Copy link
Owner

Merged. Thanks!

@willptswan
Copy link
Collaborator Author

No problem

@purplepeng
Copy link

Thanks.
There also have a small problem. The ZSSimageDevice.png image was not placed in the same path with others.
sourceimage

@willptswan
Copy link
Collaborator Author

I will submit a pull request for that to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants