想要像 ipod 应用程序一样显示和实施评级
我想像苹果在 iPod 应用程序中那样显示和实现评级。 谁能告诉我它是如何完成的。我想要实现的代码是写在viewController 中。
提前致谢。
提供代码会很有用。 我正在 touchesBegan: 方法内的 UIViewController 子类 的实现 (.m) 文件中绘制图像。 运行时的错误如下:
<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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
5 个按钮,带有您自己的填充和未填充星星图像。您需要一些自定义逻辑来更改每次点击时的图片。我建议在每个按钮上设置不同的标签。
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.
我处理它的方法是响应目标视图中的触摸,并查看视图中的触摸位置。
我会将视图分成多个部分,等于定期间隔的“星星”数量,并且当在这些部分之一中检测到触摸时,将评级值设置为部分的数量。
例如。
然后,您可以实现一些绘图来对应于所选的评级,以绘制已选择的“星星”的数量。
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.
Then you could implement some drawing to correspond to the chosen rating to draw the amount of 'stars' that have been selected.