如何使用 Titanium 为 iPhone 应用程序创建星级评级控件?
我正在使用 Titanium 框架构建 iPhone 应用程序。我的应用程序中需要一个 5 星级评级控件,就像在应用程序商店中找到的那样。作为临时解决方案,我使用滑块来添加评级。我在网上找到的大多数示例都在 Objective C 中。有人可以指导我使用钛来实现这一目标吗?
问候
I'm building an iPhone app using the Titanium framework. I need a 5-star rating control in my app, just like the one found in the app store. As a temporary solution I'm using the slider for adding a rating. Most of the examples I found on the web are in objective C. can somebody guide me on achieving this using titanium.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您只需创建一个
视图
并用您想要的按钮数量填充它,然后为它们分配一个点击事件。使用上面的逻辑方法,您应该能够更改
max
来设置您想要的星星数量,并简单地设置rate(v)
来执行以下两个选项之一上面的评论。请记住,您需要使用left
或某种类型的定位将stars[i]
添加到视图中,该定位会根据可用星星的数量递增。希望这有帮助。You just need to create a
view
and populate it with the number of buttons you want then assign a click event to them.Using that logic approach above you should be able to change
max
to set the number of stars you want and simply setup therate(v)
to do one of the two options in the comments above. Keep in mind that you need to add thestars[i]
to the view with aleft
or some type of positing that increments based on the number of stars available. Hope this helps.Appcelerator 制作了一个自定义用户界面帖子,其中包括星级评级系统。
代码:
https://github.com/appcelerator-developer-relations /Forging-Titanium/tree/master/ep-003
视频:
http://vimeopro.com/appcelerator/forging-titanium/video/28122504
Appcelerator made a custom ui posting that included a star rating system.
The Code:
https://github.com/appcelerator-developer-relations/Forging-Titanium/tree/master/ep-003
The Video:
http://vimeopro.com/appcelerator/forging-titanium/video/28122504
这是示例代码 https://github.com/dlinsin/DLStarRating
Here is a sample code https://github.com/dlinsin/DLStarRating
您不能在 Titanium 构建的应用程序中使用 Objective-C 代码吗? Titanium 用于构建本机应用程序...或者您想知道如何在 Javascript 中编写这样的东西吗?
Can you not use pieces of Objective-C code in your Titanium built application? Titanium is used for building native applications... Or do you want to know how to write something like this in Javascript?
只需您可以使用此测试(Android - IOS),
假设您需要 5 颗星进行评级,并且您的星星图像高度和宽度 = 26
我希望对您有帮助
Simply you can us this Tested on (Android - IOS)
assumed you need 5 stars for rating and your star image height and width = 26
I hope to help you
也许这会帮助您创建简单的星级评定
May be this will help you to create simple star rating