Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Add WPSAlertController.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirbyt committed Sep 26, 2015
1 parent ffb9c6e commit 3b67836
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 4 deletions.
8 changes: 8 additions & 0 deletions WPSKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
686AC0361BB309BF00D20478 /* WPSStopwatchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 686AC0281BB309BF00D20478 /* WPSStopwatchTests.m */; settings = {ASSET_TAGS = (); }; };
686AC0371BB309BF00D20478 /* WPSWebErrorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 686AC0291BB309BF00D20478 /* WPSWebErrorTests.m */; settings = {ASSET_TAGS = (); }; };
686AC0381BB309BF00D20478 /* WPSWebSessionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 686AC02A1BB309BF00D20478 /* WPSWebSessionTests.m */; settings = {ASSET_TAGS = (); }; };
68E84EA11BB6B7AC00D1D9E6 /* WPSAlertController.h in Headers */ = {isa = PBXBuildFile; fileRef = 68E84E9F1BB6B7AC00D1D9E6 /* WPSAlertController.h */; settings = {ATTRIBUTES = (Public, ); }; };
68E84EA21BB6B7AC00D1D9E6 /* WPSAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = 68E84EA01BB6B7AC00D1D9E6 /* WPSAlertController.m */; settings = {ASSET_TAGS = (); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -222,6 +224,8 @@
686AC06A1BB3761D00D20478 /* readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = readme.md; sourceTree = "<group>"; };
686AC06C1BB376CD00D20478 /* WPSKit.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WPSKit.xcconfig; sourceTree = "<group>"; };
686AC0701BB376CD00D20478 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
68E84E9F1BB6B7AC00D1D9E6 /* WPSAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WPSAlertController.h; sourceTree = "<group>"; };
68E84EA01BB6B7AC00D1D9E6 /* WPSAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WPSAlertController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -395,6 +399,8 @@
686ABF761BB309A700D20478 /* UIView+WPSKit.m */,
686ABF771BB309A700D20478 /* UIViewController+WPSKit.h */,
686ABF781BB309A700D20478 /* UIViewController+WPSKit.m */,
68E84E9F1BB6B7AC00D1D9E6 /* WPSAlertController.h */,
68E84EA01BB6B7AC00D1D9E6 /* WPSAlertController.m */,
686ABF7D1BB309A700D20478 /* WPSCollectionReusableView.h */,
686ABF7E1BB309A700D20478 /* WPSCollectionReusableView.m */,
686ABF7F1BB309A700D20478 /* WPSCollectionViewCell.h */,
Expand Down Expand Up @@ -445,6 +451,7 @@
files = (
686AC0031BB309A700D20478 /* WPSCompositeView.h in Headers */,
686ABF901BB309A700D20478 /* NSManagedObjectContext+WPSKit.h in Headers */,
68E84EA11BB6B7AC00D1D9E6 /* WPSAlertController.h in Headers */,
686ABF8D1BB309A700D20478 /* NSManagedObject+WPSKit.h in Headers */,
686ABFA21BB309A700D20478 /* NSData+WPSKit.h in Headers */,
686ABFFD1BB309A700D20478 /* WPSCollectionReusableView.h in Headers */,
Expand Down Expand Up @@ -623,6 +630,7 @@
686ABFCA1BB309A700D20478 /* WPSWebError.m in Sources */,
686ABFDD1BB309A700D20478 /* UICollectionView+WPSKit.m in Sources */,
686ABFD01BB309A700D20478 /* MKMapView+WPSKit.m in Sources */,
68E84EA21BB6B7AC00D1D9E6 /* WPSAlertController.m in Sources */,
686ABF9A1BB309A700D20478 /* WPSManagedObjectContextWatcher.m in Sources */,
686ABF941BB309A700D20478 /* WPSCoreDataStack.m in Sources */,
686AC0071BB309A700D20478 /* WPSFeedbackEmailController.m in Sources */,
Expand Down
16 changes: 16 additions & 0 deletions WPSKit/UIKit/WPSAlertController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// WPSAlertController.h
// WPSKit
//
// Created by Kirby Turner on 9/26/15.
// Copyright © 2015 White Peak Software, Inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface WPSAlertController : UIAlertController

- (void)show;
- (void)showAnimated:(BOOL)animated;

@end
50 changes: 50 additions & 0 deletions WPSKit/UIKit/WPSAlertController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// WPSAlertController.m
// WPSKit
//
// Created by Kirby Turner on 9/26/15.
// Copyright © 2015 White Peak Software, Inc. All rights reserved.
//

#import "WPSAlertController.h"

@interface WPSAlertController ()
@property (nonatomic, strong) UIWindow *alertWindow;
@end

@implementation WPSAlertController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}

- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[[self alertWindow] setHidden:YES];
[self setAlertWindow:nil];
}

- (void)show
{
[self showAnimated:YES];
}

- (void)showAnimated:(BOOL)animated
{
UIViewController *blankViewController = [[UIViewController alloc] init];
[[blankViewController view] setBackgroundColor:[UIColor clearColor]];

UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window setRootViewController:blankViewController];
[window setBackgroundColor:[UIColor clearColor]];
[window setWindowLevel:UIWindowLevelAlert + 1];
[window makeKeyAndVisible];
[self setAlertWindow:window];

[blankViewController presentViewController:self animated:animated completion:nil];
}

@end
1 change: 1 addition & 0 deletions WPSKit/WPSKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ FOUNDATION_EXPORT const unsigned char WPSKitVersionString[];
#import <WPSKit/UITextView+WPSKit.h>
#import <WPSKit/UIView+WPSKit.h>
#import <WPSKit/UIViewController+WPSKit.h>
#import <WPSKit/WPSAlertController.h>
#import <WPSKit/WPSCollectionReusableView.h>
#import <WPSKit/WPSCollectionViewCell.h>
#import <WPSKit/WPSCompositeView.h>
Expand Down
2 changes: 1 addition & 1 deletion WPSKitSamples/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="Pzg-7d-lOU">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
</dependencies>
Expand Down
7 changes: 4 additions & 3 deletions WPSKitSamples/WPSCustomDetailDisclosureButtonViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
#warning Fix Me
// NSString *message = [NSString stringWithFormat:@"Got it! (section: %zi, row: %zi)", [indexPath section], [indexPath row]];
// [WPSAlertView presentOkayAlertViewWithTitle:@"Accessory Button Tapped" message:message];
NSString *message = [NSString stringWithFormat:@"Got it! (section: %zi, row: %zi)", [indexPath section], [indexPath row]];
WPSAlertController *alert = [WPSAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
[alert show];
}

@end

0 comments on commit 3b67836

Please sign in to comment.