Posts

Showing posts from February, 2013

Star Rating in iPhone using UITouch

Image
If you have an application in which you want to take user reviews and want to provide a star rating, you are in a big trouble cause Cocoa Touch (iPhone) does not provide any UIControl for it. You have to create your own control for this using touch detection or gesture recognition. In following tutorial i have detected point of touch for achieving my goal. 1. Here i have added a UIView - viewForStarRating on which i placed 5 UIImageViews - imgViewStar1, imgViewStar2, imgViewStar3, imgViewStar4 and imgViewStar5 on my Nib file and set outlet to each. 2. Declare two CGPoints - touchStartPoint and touchCurrentPoint, these CGPoints will give me my touch coordinates. 3. In my implementation file i added touchesBegan and touchesMoved delegate methods. 4. In touchesBegan delegate :    UITouch *touch = [touches anyObject ];    self . touchStartPoint = [touch locationInView : self . viewForStarRating ];    NSLog ( @"Touch detected at: x = %f and y = %f" ,