xcode 语义问题:在“UISlider”类型的对象上找不到属性“文本”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8306789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Semantic issue: Property 'text' not found on object of type 'UISlider'
提问by pdenlinger
When I try to run it though, I get an error which says "Semantic issue: Property 'text' not found on object of type 'UISlider'"
但是,当我尝试运行它时,我收到一条错误消息,显示“语义问题:在‘UISlider’类型的对象上找不到属性‘文本’”
What's wrong here?
这里有什么问题?
Here is the code from the header file:
这是头文件中的代码:
#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
Implementation file:
实现文件:
#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
回答by Scott Forbes
I suspect your sliderLabel
has been declared as an object of class UISlider
, when it should be UILabel
. Can you verify the sliderLabel's @property
declaration in your header file?
我怀疑你sliderLabel
已经被声明为类的对象,UISlider
应该是UILabel
。你能@property
在你的头文件中验证sliderLabel的声明吗?
回答by Ha Duyen Hoa
I have the same message on NSManagedObject. My solution is set "Always Search User Paths" in "Search Paths" of target's Build Settings to "No" Hope that could help too.
我在 NSManagedObject 上有同样的消息。我的解决方案是将目标构建设置的“搜索路径”中的“始终搜索用户路径”设置为“否”希望也能有所帮助。