Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:16:07+00:00 2026-06-05T07:16:07+00:00

I have a view with 3 ratings bars on it. How do I tell

  • 0

I have a view with 3 ratings bars on it.

How do I tell them apart in the code? Right now if I change the top one it sees it fine but if I then change either or the other two it cannot separate them from one another.

The code is from git https://github.com/dyang/DYRateView

- (void)changedToNewRate:(NSNumber *)rate {
    NSString *rating = [NSString stringWithFormat:@"Rate: %d", rate.intValue];
    NSLog(@"rating: %@",rating);
}

This is where is sees the changing.

And this is the .m file

#import "Survey.h"

@implementation Survey

@synthesize btnSubmit;

- (void)setUpEditableRateView {
    DYRateView *rateService = [[DYRateView alloc] initWithFrame:CGRectMake(0, 55, self.view.bounds.size.width, 40) fullStar:[UIImage imageNamed:@"StarFullLarge@2x.png"] emptyStar:[UIImage imageNamed:@"StarEmptyLarge@2x.png"]];
    rateService.padding = 20;
    rateService.alignment = RateViewAlignmentCenter;
    rateService.editable = YES;
    rateService.delegate =self;
    [scroller addSubview:rateService];
    [rateService release];

    DYRateView *rateFood = [[DYRateView alloc] initWithFrame:CGRectMake(0, 130, self.view.bounds.size.width, 40) fullStar:[UIImage imageNamed:@"StarFullLarge@2x.png"] emptyStar:[UIImage imageNamed:@"StarEmptyLarge@2x.png"]];
    rateFood.padding = 20;
    rateFood.alignment = RateViewAlignmentCenter;
    rateFood.editable = YES;
    rateFood.delegate = self;
   [scroller addSubview:rateFood];
   [rateFood release];

  DYRateView *rateCleanliness = [[DYRateView alloc] initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, 40) fullStar:[UIImage imageNamed:@"StarFullLarge@2x.png"] emptyStar:[UIImage imageNamed:@"StarEmptyLarge@2x.png"]];
   rateCleanliness.padding = 20;
   rateCleanliness.alignment = RateViewAlignmentCenter;
   rateCleanliness.editable = YES;
   rateCleanliness.delegate = self;
   [scroller addSubview:rateCleanliness];
   [rateCleanliness release];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{

   [textField resignFirstResponder];
   return YES;
}

- (void)changedToNewRate:(NSNumber *)rate {
    NSString *rating = [NSString stringWithFormat:@"Rate: %d", rate.intValue];
    NSLog(@"rating: %@",rating);
}

- (IBAction)btnSubmit:(id)sender{

}

-(IBAction)mainMenu{

[self dismissModalViewControllerAnimated:YES];   
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [scroller setScrollEnabled:YES];
    [scroller setContentSize:CGSizeMake(320, 600)];
    scroller.BackgroundColor = [UIColor clearColor];

    [self setUpEditableRateView];

    [btnSubmit useGreenConfirmStyle];
 }


 - (void)viewDidUnload
 {
    [super viewDidUnload];
     // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
 }

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 {
     // Return YES for supported orientations
     return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }

 @end

UPDATE

ok with the new code I added an if statement

- (void)rateView:(DYRateView *)rateView changedToNewRate:(NSNumber *)rate {
    NSString *barName = [NSString stringWithFormat:@"%@", rateView];
    if (barName == @"rateView1") {
        NSString *bar1 = [NSString stringWithFormat:@"Rate: %d", rate.intValue];
        NSLog(@"bar 1: %@",bar1);
    }else if(barName == @"rateView2"){
        NSString *bar2 = [NSString stringWithFormat:@"Rate: %d", rate.intValue];
        NSLog(@"bar 2: %@",bar2);
    }else{
       NSLog(@"NO BAR: %@",barName);
    } 
  self.rateLabel.text = [NSString stringWithFormat:@"Rate: %d", rate.intValue];

  }

It works however Instead of getting back “rateView1” or 2 or 3. I get back

 NO BAR: <DYRateView: 0x78229b0; frame = (0 40; 320 20); opaque = NO; layer =
 <CALayer:0x7824900>>

Which is correct in nature but I was hoping for the name of the rateView such as “rateView1”

SOLUTION:

in .h file @property your 2 or 3 bars

@property(nonatomic, retain) DYRateView *rateView1,*rateView2;

in .m @synthesize them

@synthesize rateView1;
@synthesize rateView2;

then

(void)setUpEditableRateView {
    rateView1 = [[DYRateView alloc] initWithFrame:CGRectMake(0, 40, self.view.bounds.size.width, 20) fullStar:[UIImage imageNamed:@"StarFullLarge.png"] emptyStar:[UIImage imageNamed:@"StarEmptyLarge.png"]];
    rateView1.padding = 20;
    rateView1.alignment = RateViewAlignmentCenter;
    rateView1.editable = YES;
    rateView1.delegate = self;
    [self.view addSubview:rateView1];
    [rateView1 release];

    rateView2 = [[DYRateView alloc] initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, 20) fullStar:[UIImage imageNamed:@"StarFullLarge.png"] emptyStar:[UIImage imageNamed:@"StarEmptyLarge.png"]];
    rateView2.padding = 20;
    rateView2.alignment = RateViewAlignmentCenter;
    rateView2.editable = YES;
    rateView2.delegate = self;
    [self.view addSubview:rateView2];
    [rateView2 release];

    // Set up a label view to display rate
    self.rateLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 80, self.view.bounds.size.width, 20)] autorelease];
    self.rateLabel.textAlignment = UITextAlignmentCenter;
    self.rateLabel.text = @"Tap above to rate";
    [self.view addSubview:self.rateLabel];
}

Then Finally

- (void)rateView:(DYRateView *)rateView changedToNewRate:(NSNumber *)rate {

    if (rateView == rateView1) {
        NSString *bar1 = [NSString stringWithFormat:@"Rate: %d", rate.intValue];
        NSLog(@"bar 1: %@",bar1);
    }else if(rateView == rateView2){
        NSString *bar2 = [NSString stringWithFormat:@"Rate: %d", rate.intValue];
        NSLog(@"bar 2: %@",bar2);
    }else{
        NSLog(@"NO BAR: %@",rateView);
    }     
    self.rateLabel.text = [NSString stringWithFormat:@"Rate: %d", rate.intValue];   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:16:08+00:00Added an answer on June 5, 2026 at 7:16 am

    Thanks for using DYRateView!

    The current version of DYRateView doesn’t support listening to multiple instances all at the same time, but that doesn’t mean that we can’t do that. 🙂

    If you don’t mind updating the source code, you can find a method named notifyDelegate in DYRateView.m, and change [self.delegate performSelector:@selector(changedToNewRate:) withObject:[NSNumber numberWithFloat:self.rate]] to something like [self.delegate performSelector:@selector(rateView:changedToNewRate:) withObject:self withObject:[NSNumber numberWithFloat:self.rate]]. In this way you are able to pass the rateView itself as a parameter to its listener.

    I haven’t tried the above code yet as I don’t have access to my Mac at this point, but I think this should give you an idea regarding how to achieve your goal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have view stack in a app like so: <mx:ViewStack id=viewStack left=0 right=0 top=0
I have jquery code that is being reused by a repeatable partial view on
Hólla everybody, I have a strongly typed view and for one int Rating property,
I have such stuff in my django view: message = 'sometext' rating = 7
i have view like 'home/details/5', it can be access by anonymous user. but there
I have view controller, into the view i have put a table view, and
i have view controller which contains a button which show the image library ,if
I have view page with both detailview and gridview the grid view should be
I am beginner in rails. I have view that i try to print inside
I have a view containing a UIWebView which is loading a google map (so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.