I want to create a macos app (example.app) with EULA screen. Don't want a .dmg, as I want to run the app directly. Clicking on the app will show the EULA screen and then launch it.
Is there any way I can do that? Please help.
Make another window in your XIB. Link/connect the new window to your AppDelegate.m file with a new property EULAwindow. Make sure both windows are set to be not visible at launch.
#import "AppDelegate.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSWindow *EULAwindow;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
BOOL hasUserAgreedToEULA = [[NSUserDefaults standardUserDefaults] boolForKey:@"userHasAgreedEULA"];
if (hasUserAgreedToEULA) {
[self showAppWindow];
} else {
[[self EULAwindow] orderFront:nil];
}
}
- (IBAction)userAgreesAction:(NSButton *)sender {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"userHasAgreedEULA"];
[[self EULAwindow] close];
[self showAppWindow];
}
- (IBAction)userDisagreesAction:(NSButton *)sender {
[NSApp terminate:nil];
}
- (void)showAppWindow
{
[[self window] orderFront:nil];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.