我目前正在实现WSCoachMarksView框架,以便在第一次使用应用程序时向用户介绍功能。然而,我的viewDidAppear
中的代码给了我以下错误:Unknown receiver 'coachMarksView'; Did you mean 'WSCoachMarksView'?
我不知道为什么会发生这种情况,因为我已经在viewDidLoad
中示例化了coachMarksView
,所以它应该能识别它。
- (void)viewDidLoad
{
[super viewDidLoad];
// Setup coach marks
NSArray *coachMarks = @[
@{
@"rect": [NSValue valueWithCGRect:(CGRect){{50,168},{220,45}}],
@"caption": @"Just browsing? We'll only notify you periodically of new matches. Need it soon? We'll notify you more frequently, and match you with items that are closer to you."
},
];
WSCoachMarksView *coachMarksView = [[WSCoachMarksView alloc] initWithFrame:self.navigationController.view.bounds coachMarks:coachMarks];
[self.navigationController.view addSubview:coachMarksView];
coachMarksView.animationDuration = 0.5f;
coachMarksView.enableContinueLabel = YES;
[coachMarksView start];
}
- (void)viewDidAppear:(BOOL)animated
{
// Show coach marks
BOOL coachMarksShown = [[NSUserDefaults standardUserDefaults] boolForKey:@"WSCoachMarksShown"];
if (coachMarksShown == NO) {
// Don't show again
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WSCoachMarksShown"];
[[NSUserDefaults standardUserDefaults] synchronize];
// Show coach marks
[coachMarksView start];
// Or show coach marks after a second delay
// [coachMarksView performSelector:@selector(start) withObject:nil afterDelay:1.0f];
}
}
字符串
3条答案
按热度按时间3j86kqsm1#
您需要将coachMarksView设置为一个属性,这样您就可以访问同一个示例。coachMarksView在viewWillAppear中是未定义的:因为该作用域不知道viewDidLoad中的作用域。
要为coachMarksView创建属性,您需要在viewController中执行以下操作:
字符串
然后在viewDidLoad中
型
现在要访问该示例,只需使用self. coachMarksView。
型
以下是有关XNUMBER-C http://rypress.com/tutorials/objective-c/properties.html中的getter、setter和属性的更多信息
o4tp2gmn2#
您已经将
coachMarksView
声明为viewDidLoad
内部的局部变量。“Local”意味着它只在您声明的位置可见。尝试将其改为类的属性,以便对象可以从其所有方法访问它。(使用
self.coachMarksView
。)gcuhipw93#
把我的案子发出去,也许对某人有用:
*错误:
Unknown receiver 'RSJsonSymbol'; did you mean 'RSSymbol'? Replace 'RSJsonSymbol' with 'RSSymbol'
*原因:不包含头文件
*解决方案:包含其头文件
RSJsonSymbol.h