Giter VIP home page Giter VIP logo

misalertcontroller's Introduction

MISAlertController

If you want to use UIAlertController, but still need to support iOS 7 this project is for you.

MISAlertController is a wrapper around UIAlertController and UIAlertView / UIActionSheet. On iOS 7 MISAlertController uses UIAlertView or UIActionSheet and on iOS 8 it uses UIAlertController to show Alerts and Action Sheets.

MISAlertController uses ARC and supports iOS 7.0+

Installing

MISAlertController can be installed by CocoaPods. Simply add this line to your Podfile:

pod 'MISAlertController'

And run pod install.

Or just add the files from the MISAlertController folder to your project.

Usage

First create a MISAlertController object

MISAlertController *alertController = [MISAlertController alertControllerWithTitle:@"Title" message:@"Message" preferredStyle:UIAlertControllerStyleActionSheet];

Second, create MISAlertAction objects

MISAlertAction *cancelAction = [MISAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(MISAlertAction *action) {
    NSLog(@"Cancel");
}];

MISAlertAction *actionOne = [MISAlertAction actionWithTitle:NSLocalizedString(@"Action 1", nil) style:UIAlertActionStyleDefault handler:^(MISAlertAction *action) {
    NSLog(@"Action 1");
}];

MISAlertAction *actionTwo = [MISAlertAction actionWithTitle:NSLocalizedString(@"Action 2", nil) style:UIAlertActionStyleDefault handler:^(MISAlertAction *action) {
    NSLog(@"Action 2");
}];

Add actions to controller

[alertController addAction:cancelAction];
[alertController addAction:actionOne];
[alertController addAction:actionTwo];

Show the controller

// Show it from bottom on iPhone and centered on iPad in the view of view controller
// [alertController showInViewController:self animated:YES];

// Show from a source view, from the bottom on iPhone and via a popover on iPad
[alertController showFromSourceView:sender inViewController:self animated:YES];

Hide the controller

[alertController dismissViewControllerAnimated:YES completion:^{

}];

In the sample project you will find how to show an alert view via MISAlertController.

Creator

Michael Schneider @maicki

License

MISAlertController is available under the MIT license. See the LICENSE file for more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.