Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

10. Working with Text > Recipe: Splitting Core Text into Pages

Recipe: Splitting Core Text into Pages

As you saw in Recipe 10-15, producing Core Text attributed strings from markup helps you separate presentation from implementation. It’s a really flexible approach that lets you edit your source material without affecting your code base. The problem comes when you are dealing with text that ranges beyond a single page. For those cases, you’ll want to split the text into sections on a page-by-page basis.

Recipe 10-16 shows how you might do that. It uses a Core Text framesetter to return an array of recommended page breaks based on a given point-based page size. You can use this hand-in-hand with Recipe 10-15’s attributed strings and Chapter 5’s page view controller to automatically build a book from your marked-up text, as shown in Figure 10-11. The application shown in the figure represents Recipe 10-16’s full sample code app. It reads in text, converts it from marked-up source into an attributed string, and then breaks it into pages for display in the paged controller.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint