tags:

views:

196

answers:

2

I am developing an application where i need to charge the user based on the number of pages. Can anyone tell me how can i derive number of pages if the data is entered as multiline in textView. Thanx in advance

+3  A: 

You can use NSString's -sizeWithFont:constrainedToSize:lineBreakMode: method to calculate the space a given amount of text would occupy.

Ole Begemann
A: 

thanks for the answer. This is what i have used and it worked....

-(float)getHeightByWidth:(NSString*)myString:(UIFont*)mySize:(int)myWidth

{

    CGSize boundingSize = CGSizeMake(myWidth, CGFLOAT_MAX);
    CGSize requiredSize = [myString sizeWithFont:mySize constrainedToSize:boundingSize lineBreakMode:UILineBreakModeWordWrap];  
    return requiredSize.height;
}
Suriya
You don't accept your own answer in this case, you accept the one that helped you find a solution! You need to read Stack Overflow's FAQ. http://stackoverflow.com/faq
Emil
i have removed my answer as cjecked bt whats in case you have found the answer yourself??
Suriya