Reputation: 611
I want to display and implement the rating in the way apple does in the ipod app. Can anybody tell me how it is done. The code that i want to implement is to be written in a viewController.
Thanks in advance.
Providing the code would be useful. I am drawing the image in the implementation (.m)file of my UIViewController subclass inside touchesBegan: method. The errors at runtime are as follows:
<Error>: CGContextSaveGState: invalid context
<Error>: CGContextSetBlendMode: invalid context
<Error>: CGContextSetAlpha: invalid context
<Error>: CGContextTranslateCTM: invalid context
<Error>: CGContextScaleCTM: invalid context
<Error>: CGContextDrawImage: invalid context
<Error>: CGContextRestoreGState: invalid context
<Error>: CGContextClipToRect: invalid context
Upvotes: 1
Views: 473
Reputation: 15621
5 buttons, with your own images for filled and unfilled stars. You'll need some custom logic to change the pictures on each click. I'd recommend setting a different tag on each button.
Upvotes: 3
Reputation: 58458
The way I would approach it would be to respond to touches in the target view, and look at the touch location within the view.
I would split the view into sections, equal to the number of 'stars' at regular intervals, and when the touch is detected within one of these sections, set the value of the rating to the number of section.
Eg.
_ _ _ _ _
|_|_|_|_|_|
^ touch here = 3
Then you could implement some drawing to correspond to the chosen rating to draw the amount of 'stars' that have been selected.
Upvotes: 2