Wednesday, 4 September 2013

String Reflowing in ios webview

String Reflowing in ios webview

I have a long text that I want to reflow and display in a uiwebview with
disabled scrolling. I tried using this code: `
- (NSInteger)lengthOfString:(NSString *)str
thatFitsIntoView:(UIView *)displayView
withFont:(UIFont *)font
{
CGSize textSize = [str sizeWithFont:font
constrainedToSize:displayView.frame.size
lineBreakMode:NSLineBreakByWordWrapping];
NSInteger lengthThatFits;
CGFloat display = 414.000000;
NSLog(@"%f -%f",displayView.frame.size.width,textSize.height);
if (textSize.height > displayView.frame.size.width)
{
lengthThatFits = str.length * display / textSize.height;
} else {
lengthThatFits = str.length;
}
return lengthThatFits;
}`
to check what part of the string will fit in a single view.

No comments:

Post a Comment