Hello,

I have created a simple and elegant message-prompt view for iPad. It is called iPadMessageView, and uses blocks to receive the response from the user and send it to the presenter UIViewController.

The default view will present a semi-transparent dark background with a main title, a text message and optionally one or two buttons: “accept” or “cancel”. iPadMessageView will use blocks for reacting to the user response to the prompt options, making it easier and more clear to use it in your code.

iPadMessageView

Integration

To use it on your code, simply add the files iPadMessageView.m and iPadMessageView.h to your project, and then on your iPad ViewController, when you want to add a new message view, simply create one:

NSString * message = @"...";
NSString * title = @"...";

self.messageView = [[iPadMessageView alloc] initWithMessage: message title: title type: iPadMessageViewTypeAcceptOrCancel andResponseBlock: ^(iPadMessageViewResponse response) {
  if (response == iPadMessageViewResponseAccept) {
    // user pushed the 'accept' button
  } else if (response == iPadMessageViewResponseCancel) {
    // user pushed the 'cancel' button
  }
}];

The type parameter determines if the dialog will prompt the user for an accept/cancel response (iPadMessageViewTypeAcceptOrCancel) or will only present an ‘accept” button (iPadMessageViewTypeAcceptOnly).

Localization

iPadMessageView uses NSLocalizedString for presenting the Accept and Cancel buttons, so if you want to localize the view you just have to add in your localized.strings the following terms:

"Accept" = "...";
"Cancel" = "...";

Interface Orientation Changes

iPadMessageView registers itself for changes in orientation, and deregisters itself on being removed from the superview. The view will remove itself from its superview after returning with the responseBlock.

License

iPadMessageView is under the MIT license. However, if you find it useful, let me know, and share the love!

Download it from my github.