应用程序打开后添加欢迎消息
Adding a welcome message once app opens
我正在尝试在用户启动应用程序时显示欢迎消息。我正在使用 UIAlertController
class.
我在app delegate中添加了UIAlertController
,这里是
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
[self.window makeKeyAndVisible];
UIAlertController *alertMessage = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Welcome!", @"Welcome")
message:@"Enjoy Using the Browser"
preferredStyle:UIAlertControllerStyleAlert];
return YES;
}
我收到 alertMessage
未被使用的警告。我不知道如何前进,有任何提示或技巧吗?
您可以尝试警报视图
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Welcome!", @"Welcome")
message:@"Enjoy Using the Browser"
delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
return YES;
我认为从 application didFinishLaunchingWithOptions
显示 UIAlertController
不是最佳做法。你有两个选择。
在您加载的第一个视图控制器上显示警报控制器。
在 window 的根视图控制器上显示警报控制器。
无论哪种方式,您都需要致电 [someViewController presentViewController:alertMessage animated:YES completion:nil];
我正在尝试在用户启动应用程序时显示欢迎消息。我正在使用 UIAlertController
class.
我在app delegate中添加了UIAlertController
,这里是
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
[self.window makeKeyAndVisible];
UIAlertController *alertMessage = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Welcome!", @"Welcome")
message:@"Enjoy Using the Browser"
preferredStyle:UIAlertControllerStyleAlert];
return YES;
}
我收到 alertMessage
未被使用的警告。我不知道如何前进,有任何提示或技巧吗?
您可以尝试警报视图
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Welcome!", @"Welcome")
message:@"Enjoy Using the Browser"
delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
return YES;
我认为从 application didFinishLaunchingWithOptions
显示 UIAlertController
不是最佳做法。你有两个选择。
在您加载的第一个视图控制器上显示警报控制器。
在 window 的根视图控制器上显示警报控制器。
无论哪种方式,您都需要致电 [someViewController presentViewController:alertMessage animated:YES completion:nil];