【发布时间】:2021-02-04 09:07:40
【问题描述】:
我有一个“条款和条件”控制器,我在第一次启动应用程序时代表,但是当第一次从 App Store 页面打开应用程序时,没有显示“条款和条件”控制器 - 仅在我关闭后应用程序并从设备本身(不是 App Store 页面)重新打开它,然后显示控制器。
这段代码来自启动的屏幕控制器:
- (void)viewDidLoad {
[self agreedToServerTerms];
}
- (void)agreedToServerTerms {
[[HttpUtils instance] httpRequest:TERMS_AGREEMENT_URL :params completionHandler:^(NSData *data, NSError *error) {
@try {
bool acceptTerms = false;
if (error) {
[Utils log:[NSString stringWithFormat:@"agreedToServerTerms error=%@", error]];
} else {
NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
if (!error) {
acceptTerms = [jsonData.allValues[0] boolValue];
if (!acceptTerms) {
TermsAndConditionController *tac = [[TermsAndConditionController alloc] initWithNibName:@"TermsAndConditionController" bundle:nil];
tac.delegate = self;
[[SlideNavigationController sharedInstance] pushViewController:tac animated:false];
}
else {
[self performSelectorInBackground:@selector(initialApp) withObject:nil];
}
} else {
[Utils log:[NSString stringWithFormat:@"parsing jsonData error = %@" ,error]];
}
}
} @catch (NSException *e) {
[Utils log:[NSString stringWithFormat:@"Exception occurred: %@, %@", e, [e userInfo]]];
}
}];
}
来自应用委托:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
LaunchScreenController *bbp = [[LaunchScreenController alloc] initWithNibName:@"LaunchScreenController" bundle:nil];
[[SlideNavigationController sharedInstance] pushViewController:bbp animated:YES];
if (_launchedURL) {
bbp.launchedURL = _launchedURL;
}
[self.window addSubview:bbp.view];
}
【问题讨论】:
-
可能显示您如何启动应用程序或如何启动此特定控制器
-
已添加,我也在 ipad 中检查过,但从 App Store 打开时应用会按预期打开
-
我认为你需要做一些不同的事情 - 如何取决于你的应用程序的其余部分。我认为您不应该在此处向窗口添加子视图。相反,在显示的第一个 VC 中,在那里执行一些检查,然后显示您的 TnC VC。我将发布一个示例...
标签: ios objective-c uiviewcontroller