• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
WebView in a modal window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

WebView in a modal window


  • Subject: WebView in a modal window
  • From: Konidaris Christos <email@hidden>
  • Date: Tue, 08 Dec 2015 20:37:07 +0200

Hi,

I have a simple window with a WebView and an NSButton that I want to display as a modal window. The window is loaded from a NIB using MyCompanyAlertController, that also acts as the WebView's delegate (set in the NIB).

When run as a sheet in my main window (using method showAlertInSheet: below) the webView loads its contents and calls its didFinishLoadForFrame: delegate method as expected. I cannot make it work when I am trying to display the window as an NSApp modal window with method showAlertModal: below. What is that I am missing? I am using Xcode 7.1 on OS X 10.11.1 and deployment target is set to 10.9.

Thanks for any help,

- Christos Konidaris


- (void) showAlertInSheet: (NSDictionary *) alertDict
{
	MyCompanyAlertController	*alertWC = [[MyCompanyAlertController alloc] initWithAlert: alertDict];

	NSWindow *alertWindow = [alertWC window];

	[alertWC initLoading];

	[self.window beginSheet: alertWindow completionHandler: ^(NSModalResponse returnCode) {

		[alertWindow orderOut: nil];
		[alertWindow close];

		[self performSelector: aSelector];
	}];
}


- (void) showAlertModal: (NSMutableDictionary *) alertDict
{
	MyCompanyAlertController	*alertWC = [[MyCompanyAlertController alloc] initWithAlert: alertDict];

	NSWindow *alertWindow = [alertWC window];

	[alertWC initLoading];

	NSModalSession	theSession = [NSApp beginModalSessionForWindow: alertWindow];
	NSInteger		response = NSModalResponseContinue;

	while (response == NSModalResponseContinue)
	{
		response = [NSApp runModalSession: theSession];

		[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
	}
	[NSApp endModalSession: theSession];

	[[alertWC window] orderOut: nil];
	…
}

- (void) initLoading
{
	NSString *messageUrl = [self.alertDict objectForKey: @"message-url"];

	self.window.title = [alertDict objectForKey: @"title”];

	[theWebview setPolicyDelegate: self];

	if ((messageUrl != nil) && ([messageUrl length] > 0))
	{
		NSURL *reqURL = [NSURL URLWithString: messageUrl];

		[[theWebview mainFrame] loadRequest: [NSURLRequest requestWithURL: reqURL]];
	}
}


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: LSSharedFIleList API deprecated
  • Next by Date: Adding minutes to display time
  • Previous by thread: Re: LSSharedFIleList API deprecated
  • Next by thread: Adding minutes to display time
  • Index(es):
    • Date
    • Thread