Ok, so yes, the answer is that it is impossible without using private APIs.
I managed to do it with the following code.
- (void) getMFComposeBodyFieldViewFromView:(UIView *)view {
for (UIView *item in view.subviews) {
if ([[[item class] description] isEqualToString:@"MFComposeTextContentView"]) {
self.mailBodyView = item;
break;
}
if([item.subviews count] > 0) {
[self getMFComposeBodyFieldViewFromView:item];
}
}
}
Then call the above method so that it sets the ivar mailBodyView
and then call the _setEditable:
method on UIWebDocumentView
which MFComposeBodyField
inherits from.
[self getMFComposeBodyFieldViewFromView:mailComposeViewController.view];
[self.mailBodyView setEditable:NO];
This causes the content in the body to be uneditable, the interaction is kind of funky because the keyboard still appears and you can still move the cursor around and select things but it definitely prevents the user from editing.
UPDATE
I updated the code to look for MFComposeTextContentView
which is the parent of MFComposeBodyField
and I call setEditable:
on that object which prevents the keyboard from coming up, much better solution!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…