gpt4 book ai didi

ios - 如何让 WSC​​oachMarksView 演练只在用户第一次打开应用程序时运行?

转载 作者:行者123 更新时间:2023-11-29 02:29:25 24 4
gpt4 key购买 nike

我正在使用 WSCoachMarksView让我的用户在他们第一次打开应用程序时进行演练,我显然只希望它在第一次运行时运行,之后再也不会运行。我按照文档中的说明进行操作,该文档告诉您将我拥有的相应代码放入 viewDidAppear 中,以便它只运行一次,但它似乎不起作用。

每次打开应用程序时,它仍然会贯穿整个演练。有什么我没有做正确的事情来检测以前运行的应用程序并设置 BOOL 以使其不再运行吗?

SearchViewController.m:

- (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."
},
];

self.coachMarksView = [[WSCoachMarksView alloc] initWithFrame:self.tabBarController.view.bounds coachMarks:coachMarks];
[self.tabBarController.view addSubview:self.coachMarksView];
self.coachMarksView.animationDuration = 0.5f;
self.coachMarksView.enableContinueLabel = YES;

[self.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
[self.coachMarksView start];
}
}

最佳答案

在 viewDidLoad 中,无论您在 NSUserDefaults 中设置了什么,您总是会开始介绍。 viewDidAppear中的勾选是正确的,但是此时已经在播放了

关于ios - 如何让 WSC​​oachMarksView 演练只在用户第一次打开应用程序时运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27093250/

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