语义问题:在'UISlider'类型的对象上找不到属性'text'

时间:2011-11-29 06:29:01

标签: xcode

当我尝试运行它时,我收到一条错误,上面写着“语义问题:在'UISlider'类型的对象上找不到属性'文本'”

这里有什么问题?

以下是头文件中的代码:

    #import <UIKit/UIKit.h>

@interface BIDViewController : UIViewController

@property (strong, nonatomic) IBOutlet UITextField *nameField;
@property (strong, nonatomic) IBOutlet UITextField *numberField;
@property (strong, nonatomic) IBOutlet UISlider *sliderLabel;

- (IBAction)textFieldDoneEditing:(id)sender;
- (IBAction)backgroundTap:(id)sender;
- (IBAction)sliderChanged:(id)sender;



@end

实施档案:

    #import "BIDViewController.h"

@implementation BIDViewController
@synthesize sliderLabel;
@synthesize nameField;
@synthesize numberField;

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

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

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

- (IBAction)textFieldDoneEditing:(id)sender
{
[sender resignFirstResponder];
}   

- (IBAction)backgroundTap:(id)sender
 {
    [nameField resignFirstResponder];
    [numberField resignFirstResponder];
 }

- (IBAction)sliderChanged:(id)sender
{
    UISlider *slider = (UISlider *)sender;
    int progressAsInt = (int)roundf(slider.value);
    sliderLabel.text = [NSString stringWithFormat:@"%d",progressAsInt];
}

@end

2 个答案:

答案 0 :(得分:3)

我怀疑您的sliderLabel已被声明为类UISlider的对象,而它应该是UILabel。你能在头文件中验证sliderLabel的@property声明吗?

答案 1 :(得分:0)

我在NSManagedObject上有相同的消息。我的解决方案是将目标的Build Settings的“Search Paths”中的“Always Search User Paths”设置为“No” 希望这也有帮助。