gpt4 book ai didi

iphone - 手势识别星级评定系统

转载 作者:行者123 更新时间:2023-11-28 23:10:34 27 4
gpt4 key购买 nike

我在 https://github.com/dlinsin/DLStarRating 使用了这个星级评分系统该手势工作正常,但它似乎没有正确使用委托(delegate),因此当我选择一颗星时,评级不会刷新。这是我的代码:

.main 文件

- (void)viewDidLoad
{

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

//check if value has been previously saved
if( ![defaults stringForKey:@"username"] ) {

CustomerLogin *customerlogin = [[CustomerLogin alloc]
initWithNibName:@"CustomerLogin" bundle:nil];
[self presentModalViewController:customerlogin animated:YES];
// customerlogin.view.frame = CGRectMake(0, 0, 700, 900);
// customerlogin.view.center = CGPointMake( 768/2, 1024/2);
//[self.navigationController pushViewController:customerlogin animated:YES];

[customerlogin release];


}

UIBarButtonItem * sortButton = [[UIBarButtonItem alloc] initWithTitle:@"Submit" style:UIBarButtonItemStyleBordered target:self action:@selector(Submit)];

self.navigationItem.rightBarButtonItem = sortButton;
[sortButton release];

rating.delegate = self;
comments.delegate = self;
bestnight.delegate = self;

UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background_texture.png"]];

self.view.backgroundColor = background;

[background release];

self.title = @"Write Review";

[super viewDidLoad];

//Star touch
DLStarRatingControl *customNumberOfStars = [[DLStarRatingControl alloc] initWithFrame:CGRectMake(0,0, 320, 100) andStars:5];
customNumberOfStars.backgroundColor = [UIColor clearColor];
customNumberOfStars.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
customNumberOfStars.rating = 3;
[self.view addSubview:customNumberOfStars];
[customNumberOfStars release];

}

-(void)newRating:(DLStarRatingControl *)control :(NSUInteger)rating
{
self.rating.text = [NSString stringWithFormat:@"%d star rating",rating];
}

.头文件

#import "DLStarRatingControl.h"

@class Customer;
@class Place;

@interface CreateReview : UIViewController <UITextFieldDelegate,UITextViewDelegate,DLStarRatingDelegate>
{
Customer*customer;
Place*place;
IBOutlet UITextField * bestnight;
IBOutlet UITextView * comments;
IBOutlet UITextField * rating;
IBOutlet UILabel * testValueLabel;

NSString * identifier;
NSString * password;
NSString * username;


}

@property (nonatomic, retain) IBOutlet UITextField * bestnight;
@property (nonatomic, retain) IBOutlet UITextView * comments;
@property (nonatomic, retain) IBOutlet UITextField * rating;
@property (nonatomic, retain) Customer*customer;
@property (nonatomic, retain) Place*place;
@property (nonatomic, retain) IBOutlet UILabel * testValueLabel;
@property (nonatomic, retain) NSString * identifier;
@property (nonatomic, retain) NSString * password;
@property (nonatomic, retain) NSString * username;

-(id)initWithPlace:(Place*)p;
-(void)newRating:(DLStarRatingControl *)control :(NSUInteger)rating;


@end

最佳答案

看来您没有为 DLStarRatingControl 设置委托(delegate):

尝试在设置评分控件时添加 customNumberOfStars.delegate = self;

关于iphone - 手势识别星级评定系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8402193/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com