Reputation: 1488
I have a flip view controller that flips (instead of the default scrolling) through text. I added a txt file to the project and (since it has 50,000 characters) used the "substringWithRange" method to create a substring for each page. I have a set number of characters in each page, but they display differently. I'd like to know how to get them to display exactly the same. meaning I (eventually) want the text to go to the end of the page, but when I try that, some text gets cut off.
Heres the code I'm using to substring the text
if (self.pageIndex == 1)//self.txt is the string that has the entire .txt file in it. For each page I'm substringing it.
{
self.txt = [self.txt substringWithRange:NSMakeRange(0,1300)];
}
if (self.pageIndex == 2)
self.txt = [self.txt substringWithRange:NSMakeRange(1300,1300)];
Heres an example. Please let me know if you need any other info
page 1
page 2
they are ending at different physical locations even though I made them the exact same amount of characters
even with courier (fixed font, apparently), the text is still different for each page
Upvotes: 0
Views: 21
Reputation: 318814
It's a proportional font. The width of 10 i
s is different than the width of 10 m
s.
Proportional font:
iiiiiiiiii
mmmmmmmmmm
Fixed-width font:
iiiiiiiiii mmmmmmmmmm
Either use a fixed-width font or find a way to extract the proper number of characters for each page based on the desired text length for the given font.
Update:
Even with a fixed width font, you are using word wrapping. Different length words mean each line is comprised of different numbers of letters.
You really only have two choices:
Upvotes: 1