tailieunhanh - Praise for The iPhone Developer’s Cookbook 2nd phần 5
các thanh công cụ là cung cấp một vốn từ vựng của các hành động mà hành động hiện tại thanh công cụ được sử dụng trong ứng dụng Mail cho phép bạn xóa tin nhắn hoặc trả lời hình ảnh hiện tại đơn sắc trên mỗi nút. Nếu ý tưởng thiết kế của bạn bao gồm các thanh tab | Recipe Calculating Lines 323 CGContextAddLineToPoint context CGContextStrokePath context @end Get This Recipe s Code To get the code used for this recipe go to http erica or if you ve downloaded the disk image containing all of the sample code from the book go to the folder for Chapter 8 and open the project for this recipe. Recipe Calculating Lines When user input relies primarily on touches applied geometry can help interpret those gestures. In this recipe and the next computational solutions filter user input to create simpler data sets that are more application appropriate. Recipe 8-10 collects the same touch array that was shown in Recipe the gesture finishes that is at touch-up this code analyzes that array and creates a minimized set of line segments to match the freeform points. A reduced point set accomplishes two things. First it creates a straighter better-looking presentation. The right image in Figure 8-5 is much cleaner than the one on the left. Second it produces a set of points that are better matched to six-point line segments shown in Figure 8-5 on the right are far easier to analyze than the more than 50 points on the left. The extra line segments are due to a slight finger squiggle at the top-right of the triangle. Converting a freeform gesture into meaningful user intent can be a significantly hard problem. Although it s obvious to a human that the user meant to draw a triangle computational algorithms are never you need to interpret gestures a certain amount of hand waving accommodation is necessary. Recipe 8-10 works by analyzing sets of three points at a time. For each triplet it centers the first and third points around the origin of the second. It then takes the dot product of the vectors to the first and third points. The dot product returns a value that is the cosine of the angle between the two vectors. If those points are collinear that is the angle .
đang nạp các trang xem trước