Tony UK
Tony UK

Reputation: 412

mfmailcomposer cuts end of html email

I've created an in app email feature to ask a question that opens the mfmailcomposer and fills it with html content. Unfortunately it seems to cut off the final line of the email so it appears as the image below.

Here's an example

I have set the mfmailcomposer to self, followed every tutorial I can find, the only reference to fix it has said the following:

  1. make sure your mfmailcomposer is set to self ie. [self presentModalViewController:email animated:YES];
  2. make sure it's embedded within a navigation controller

Neither solution works.

I have found that if the email contents is short enough that the entire email fits on screen the problem doesn't appear but if you continue typing to push the contents off the edge it reappears.

Any ideas on a solution? Or is this an Apple xcode "design feature"?

Upvotes: 0

Views: 262

Answers (2)

Tony UK
Tony UK

Reputation: 412

I managed to resolve this issue, it seems to be a bug, that's the only explanation I can reach.

If the start of your content is a header (<h1>, <h2>, <h3>, etc) tag (even if it is within a HTML and BODY tag) it creates this issue.

If you want to start your email body with a header tag then the simplest way of fixing it is to add a non breaking spacer before the header tag, it seems to completely resolve the issue.

Upvotes: 1

Ivan Vučica
Ivan Vučica

Reputation: 9679

Possibly a framework bug. Does it occur on different versions of iOS? Try it with both older and newer versions of the operating system and on other devices.

Are you 100% certain that the view is not actually larger than its container view? Explore the view hierarchy. Perhaps in plaintext Apple adds some spacing, so it doesn't seem like the content is out of bounds of the parent view, although it is.

How do scroll indicators behave? Are they also clipped?

Are you presenting the message composer in a fullscreen view? If you're trying to present it in a view that is controlled by a sub-controller of the tab view controller, that might cause the composer view controller to be confused.

For what it's worth, I've just tested my code which generates HTML content, and there is no clipping. This is on iOS 4.2.1 on iPhone 3G, but I don't remember seeing the problem on iOS 5.1 either.


Some tips.

While debugging, don't forget: view controllers are actually just managing views that still have their own hierarchies. To clarify, view controllers may have a hierarchy, but their hierarchy does not necessarily correspond to view hierarchy. (Although it should in the near total majority of cases.) Same thing with views themselves: they have their hierarchy, but they still just control the underlying Core Animation layers, which have their own hierarchy.

You can always access view hierarchy itself and explore it in greater detail through debugging facilities you come up with yourself. What you shouldn't be doing is meddling too much in parts of the view hierarchy that's supposed to be managed by the view controllers, just like you shouldn't mess too much with the parts of the layer hierarchy that's supposed to be managed by the views.

Upvotes: 0

Related Questions