为 iPhone 评分

发布于 2024-10-11 14:32:49 字数 695 浏览 2 评论 0 原文

我一直在寻找 5 星级评级控件,但尚未找到可靠的解决方案。 这个问题:

有人知道是否有iPhone 上的 5 星级组件?

提供了一些不再可用的项目链接,但我无法找到它们。

编辑:我显然不擅长跟踪项目,但我认为我的部分问题仍然存在。以下是更新后的链接 http://code .google.com/p/s7 ratingview/downloads/detail?name=s7atingview-basic-release.zip

所以这个问题分为两部分 - 是否有可靠的预制解决方案,您能指导我吗?

开发自己的解决方案是否更好/相当容易(是的,我意识到这两个方面是冲突的)?您能给我一些提示/资源吗?我理解子类化 UIView 和跟踪触摸事件以将图像扩展到另一个图像上以看起来像星星的基本思想,但更多的方向会有所帮助。我在 iPhone 上进行开发已经不到一周了,仍然需要一些指导。

I have been looking for a 5-Star rating control for a while now and have not found a solid solution.
This question:

Anyone know whether there is a 5-star rating component on iPhone?

Provided a couple of links to projects which are no longer available, and i have not been able to track them down.

Edit: I am apparently bad at tracking down projects, but I think part of my question still stands. Here is the updated link http://code.google.com/p/s7ratingview/downloads/detail?name=s7ratingview-basic-release.zip

So this questions is 2 part - Is there a solid premade solution out there, and could you direct me to it?

Is it better / fairly easy to (yes, i realize these two facets are in conflict) grow my own solution? Could you give me some tips/resources to do so. I understand the basic idea of subclassing UIView and tracking touch events to expand an image ontop of another image to look like stars, but a little more direction would be helpful. I have been developing on the iphone for a little under a week and still need a bit of hand-holding.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

愁杀 2024-10-18 14:32:49

您可以尝试一下DYRateView。我想尽可能地重用 Ray 教程中的那个,但是其中缺少几个功能,所以我自己制作了一个。

您可以查看我的博客,了解有关如何在项目中使用 DYRateView 的更多详细信息:http://iappexperience.com/post/23227218867/dyrateview-a-simple-yet-powerful- rating-control-for

图片

“图片”

You can give DYRateView a try. I wanted to reuse the one in Ray's tutorial as much as possible, but there were several features missing from it, so I made one myself.

You can check out my blog for further details on how to use DYRateView in your project: http://iappexperience.com/post/23227218867/dyrateview-a-simple-yet-powerful-rating-control-for.

picture

picture

清旖 2024-10-18 14:32:49

尝试 Ray Wenderlich 的 具有 5 星级评级的自定义 UIView。


[编辑]

您还可以尝试使用 UISlider 并提供最小/最大轨道图像。

Try Ray Wenderlich's custom UIView with a 5-star rating.


[EDIT]

You can also try using UISlider and supplying a minimum/maximum track images.

清旖 2024-10-18 14:32:49

您可以尝试的另一种方法 DLStarRating 可让您自定义星星下方的区域,检测触摸。

在此处输入图像描述

Another way you may try DLStarRating lets you customize the area below the stars, detecting touches.

enter image description here

贪了杯 2024-10-18 14:32:49

只需简单地给一颗星即可遵循此代码并将其复制并粘贴到您的项目中并轻松运行。

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    startview = [[UIView alloc] initWithFrame:CGRectMake(45, 70, 230, 50)];
    startview.backgroundColor = [UIColor redColor];
    NSInteger getrating = 0;
    int x = 5;
    for (int k = 1; k <= 5; k++)
    {
        UIImageView * mystarimage = [[UIImageView alloc] initWithFrame:CGRectMake(x, 5, 40, 40)];

        if (getrating >= k)
        {
            mystarimage.image = [UIImage imageNamed:@"star.png"];
        }
        else
        {
            mystarimage.image = [UIImage imageNamed:@"gray-star.png"];
        }

        mystarimage.tag = k;
        mystarimage.userInteractionEnabled = YES;
        [startview addSubview:mystarimage];
        UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(updateStar:)];
        rateMember = mystarimage.tag;
        NSLog(@"rateing %ld",(long)rateMember);
        letterTapRecognizer.numberOfTapsRequired = 1;
        [mystarimage addGestureRecognizer:letterTapRecognizer];
        x = x + 45;
    }
    [self.view addSubview:startview];
}

-(void)updateStar :(UITapGestureRecognizer*)sender
{
    UIView *view = sender.view;
    NSLog(@"hello ji %ld", (long)view.tag);
    NSInteger getrating;

    switch (view.tag)
    {
        case 1:
            NSLog(@"press 1");
            rateMember = 1;
            break;
        case 2:
            NSLog(@"press 2");
            rateMember = 2;
            break;
        case 3:
            NSLog(@"press 3");
            rateMember = 3;
            break;
        case 4:
            NSLog(@"press 4");
            rateMember = 4;
            break;
        case 5:
            NSLog(@"press 4");
            rateMember = 5;
            break;
        default:
            NSLog(@"press 5");
            rateMember = 5;
            break;
    }

    getrating = rateMember;
    NSLog(@"Get rating -------> %ld",(long)getrating);
    int x = 5;
    for (int k = 1; k <= 5 ; k++)
    {
        UIImageView * mystarimage = [[UIImageView alloc] initWithFrame:CGRectMake(x, 5, 40, 40)];

        if (getrating >= k)
        {
            mystarimage.image = [UIImage imageNamed:@"star.png"];
        }
        else
        {
            mystarimage.image = [UIImage imageNamed:@"gray-star.png"];
        }
        mystarimage.tag = k;
        mystarimage.userInteractionEnabled = YES;
        [startview addSubview:mystarimage];
        UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(updateStar:)];
        letterTapRecognizer.numberOfTapsRequired = 1;
        [mystarimage addGestureRecognizer:letterTapRecognizer];
        x = x + 45;
    }
}

Just Easy to Give a Star Follow this Code and Copy and Paste into Your Project and Simply Run.

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    startview = [[UIView alloc] initWithFrame:CGRectMake(45, 70, 230, 50)];
    startview.backgroundColor = [UIColor redColor];
    NSInteger getrating = 0;
    int x = 5;
    for (int k = 1; k <= 5; k++)
    {
        UIImageView * mystarimage = [[UIImageView alloc] initWithFrame:CGRectMake(x, 5, 40, 40)];

        if (getrating >= k)
        {
            mystarimage.image = [UIImage imageNamed:@"star.png"];
        }
        else
        {
            mystarimage.image = [UIImage imageNamed:@"gray-star.png"];
        }

        mystarimage.tag = k;
        mystarimage.userInteractionEnabled = YES;
        [startview addSubview:mystarimage];
        UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(updateStar:)];
        rateMember = mystarimage.tag;
        NSLog(@"rateing %ld",(long)rateMember);
        letterTapRecognizer.numberOfTapsRequired = 1;
        [mystarimage addGestureRecognizer:letterTapRecognizer];
        x = x + 45;
    }
    [self.view addSubview:startview];
}

-(void)updateStar :(UITapGestureRecognizer*)sender
{
    UIView *view = sender.view;
    NSLog(@"hello ji %ld", (long)view.tag);
    NSInteger getrating;

    switch (view.tag)
    {
        case 1:
            NSLog(@"press 1");
            rateMember = 1;
            break;
        case 2:
            NSLog(@"press 2");
            rateMember = 2;
            break;
        case 3:
            NSLog(@"press 3");
            rateMember = 3;
            break;
        case 4:
            NSLog(@"press 4");
            rateMember = 4;
            break;
        case 5:
            NSLog(@"press 4");
            rateMember = 5;
            break;
        default:
            NSLog(@"press 5");
            rateMember = 5;
            break;
    }

    getrating = rateMember;
    NSLog(@"Get rating -------> %ld",(long)getrating);
    int x = 5;
    for (int k = 1; k <= 5 ; k++)
    {
        UIImageView * mystarimage = [[UIImageView alloc] initWithFrame:CGRectMake(x, 5, 40, 40)];

        if (getrating >= k)
        {
            mystarimage.image = [UIImage imageNamed:@"star.png"];
        }
        else
        {
            mystarimage.image = [UIImage imageNamed:@"gray-star.png"];
        }
        mystarimage.tag = k;
        mystarimage.userInteractionEnabled = YES;
        [startview addSubview:mystarimage];
        UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(updateStar:)];
        letterTapRecognizer.numberOfTapsRequired = 1;
        [mystarimage addGestureRecognizer:letterTapRecognizer];
        x = x + 45;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文