tailieunhanh - Phát triển ứng dụng cho iPhone và iPad - part 11
Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 11', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Customizing the TableView 69 Next you implement the method setProduct that is called from the custom cell - void setProduct Product inputProduct dmmloadon If a different product is passed in. if theProduct inputProduct Clean up the old product theProduct release theProduct inputProduct Hang on to the new product theProduct retain Mark the view to be redrawn self setNeedsDisplay This method does a couple of things. First it sets the product to be displayed and then it marks the view to be redrawn. You should never directly call the drawRect method to redraw a view. The proper way to trigger a redraw is to tell the framework that a view needs to be redrawn. The framework will then call drawRect for you when it is time to redraw. Implementing drawRect Now you get to the real meat of this example drawing the view. This is done in the drawRect function and is relatively straightforward 0- void drawRect CGRect rect Drawing code Available for download on Draw the product text drawAtPoint CGPointMake forWidth 120 withFont UIFont systemFontOfSize minFontSize actualFontSize NULL lineBreakMode UILineBreakModeTailTruncation baselineAdjustment UIBaselineAdjustmentAlignBaselines Set to draw in dark gray UlColor darkGrayColor set Draw the manufacturer label drawAtPoint CGPointMake forWidth 120 withFont UIFont systemFontOfSize minFontSize actualFontSize NULL 70 I CHAPTER 3 DISPLAYING YOUR DATA THE UITABLEVIEW lineBreakMode UILineBreakModeTailTruncation baselineAdjustment UIBaselineAdjustmentAlignBaselines Set to draw in black UIColor blackColor set Draw the price label NSNumber numberWithFloat stringValue drawAtPoint CGPointMake forWidth 60 withFont UIFont systemFontOfSize minFontSize actualFontSize NULL lineBreakMode UILineBreakModeTailTruncation baselineAdjustment UIBaselineAdjustmentAlignBaselines Draw the images NSString filePath .
đang nạp các trang xem trước