Making FBDialog.h Modal

UPDATE: I submitted a patch for this issue to the latest version of the Facebook iOS SDK, and it was recently approved.

FBConnect (now Facebook iOS SDK) for iPhone is a cool way to interact your App with Facebook. The FBDialog.h class is also a pretty cool way to display a HTML page to the user in a modal way.

Yeah it’s open source too (Apache 2.0) so no problem with appropriating it for other uses :D

However it’s not totally modal. You can still interact with the underlying view on the edges.  This is especially bad on the iPad where the dialog is much smaller than the screen.

Fixing this fortunately is easy:

Under – (void)show, replace:

[window addSubview:self];

with:

_modalView.frame = window.frame;
[_modalView addSubview:self];
[window addSubview:_modalView];

And in – (void)postDismissCleanup, replace

[self removeFromSuperview];

with

[_modalView removeFromSuperview];

Just add a member UIView* _modalView, init and release in the classes init and dealloc respectively :)

Easy.

Thanks @facebook for the useful code!


One comment on “Making FBDialog.h Modal

  1. Would you care to explain how we can implement the use of FBDialog to display html page?