diff --git a/NYAlertViewController.xcodeproj/project.pbxproj b/NYAlertViewController.xcodeproj/project.pbxproj new file mode 100644 index 0000000..107f125 --- /dev/null +++ b/NYAlertViewController.xcodeproj/project.pbxproj @@ -0,0 +1,299 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + CCE96FDA1BF61E4D003A01B6 /* NYAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = CCE96FD61BF61E4D003A01B6 /* NYAlertView.m */; }; + CCE96FDB1BF61E4D003A01B6 /* NYAlertViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCE96FD71BF61E4D003A01B6 /* NYAlertViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CCE96FDC1BF61E4D003A01B6 /* NYAlertViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CCE96FD81BF61E4D003A01B6 /* NYAlertViewController.m */; }; + CCE96FE11BF61F6D003A01B6 /* NYAlertView.h in Headers */ = {isa = PBXBuildFile; fileRef = CCE96FD51BF61E4D003A01B6 /* NYAlertView.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + CCE96FCA1BF61D44003A01B6 /* NYAlertViewController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NYAlertViewController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CCE96FD51BF61E4D003A01B6 /* NYAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NYAlertView.h; sourceTree = ""; }; + CCE96FD61BF61E4D003A01B6 /* NYAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NYAlertView.m; sourceTree = ""; }; + CCE96FD71BF61E4D003A01B6 /* NYAlertViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NYAlertViewController.h; sourceTree = ""; }; + CCE96FD81BF61E4D003A01B6 /* NYAlertViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NYAlertViewController.m; sourceTree = ""; }; + CCE96FE01BF61F35003A01B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = NYAlertViewController/Info.plist; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CCE96FC61BF61D44003A01B6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CCE96FC01BF61D44003A01B6 = { + isa = PBXGroup; + children = ( + CCE96FCC1BF61D44003A01B6 /* NYAlertViewController */, + CCE96FCB1BF61D44003A01B6 /* Products */, + ); + sourceTree = ""; + }; + CCE96FCB1BF61D44003A01B6 /* Products */ = { + isa = PBXGroup; + children = ( + CCE96FCA1BF61D44003A01B6 /* NYAlertViewController.framework */, + ); + name = Products; + sourceTree = ""; + }; + CCE96FCC1BF61D44003A01B6 /* NYAlertViewController */ = { + isa = PBXGroup; + children = ( + CCE96FD51BF61E4D003A01B6 /* NYAlertView.h */, + CCE96FD61BF61E4D003A01B6 /* NYAlertView.m */, + CCE96FD71BF61E4D003A01B6 /* NYAlertViewController.h */, + CCE96FD81BF61E4D003A01B6 /* NYAlertViewController.m */, + CCE96FDD1BF61E9F003A01B6 /* Supporting Files */, + ); + path = NYAlertViewController; + sourceTree = ""; + }; + CCE96FDD1BF61E9F003A01B6 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + CCE96FE01BF61F35003A01B6 /* Info.plist */, + ); + path = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + CCE96FC71BF61D44003A01B6 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + CCE96FDB1BF61E4D003A01B6 /* NYAlertViewController.h in Headers */, + CCE96FE11BF61F6D003A01B6 /* NYAlertView.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + CCE96FC91BF61D44003A01B6 /* NYAlertViewController */ = { + isa = PBXNativeTarget; + buildConfigurationList = CCE96FD21BF61D44003A01B6 /* Build configuration list for PBXNativeTarget "NYAlertViewController" */; + buildPhases = ( + CCE96FC51BF61D44003A01B6 /* Sources */, + CCE96FC61BF61D44003A01B6 /* Frameworks */, + CCE96FC71BF61D44003A01B6 /* Headers */, + CCE96FC81BF61D44003A01B6 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = NYAlertViewController; + productName = NYAlertViewController; + productReference = CCE96FCA1BF61D44003A01B6 /* NYAlertViewController.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CCE96FC11BF61D44003A01B6 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0710; + ORGANIZATIONNAME = "Nealon Young"; + TargetAttributes = { + CCE96FC91BF61D44003A01B6 = { + CreatedOnToolsVersion = 7.1.1; + }; + }; + }; + buildConfigurationList = CCE96FC41BF61D44003A01B6 /* Build configuration list for PBXProject "NYAlertViewController" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = CCE96FC01BF61D44003A01B6; + productRefGroup = CCE96FCB1BF61D44003A01B6 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CCE96FC91BF61D44003A01B6 /* NYAlertViewController */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + CCE96FC81BF61D44003A01B6 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + CCE96FC51BF61D44003A01B6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CCE96FDC1BF61E4D003A01B6 /* NYAlertViewController.m in Sources */, + CCE96FDA1BF61E4D003A01B6 /* NYAlertView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + CCE96FD01BF61D44003A01B6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + CCE96FD11BF61D44003A01B6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + CCE96FD31BF61D44003A01B6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = NYAlertViewController/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.nealonyoung.NYAlertViewController; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + CCE96FD41BF61D44003A01B6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = NYAlertViewController/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.nealonyoung.NYAlertViewController; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CCE96FC41BF61D44003A01B6 /* Build configuration list for PBXProject "NYAlertViewController" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CCE96FD01BF61D44003A01B6 /* Debug */, + CCE96FD11BF61D44003A01B6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CCE96FD21BF61D44003A01B6 /* Build configuration list for PBXNativeTarget "NYAlertViewController" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CCE96FD31BF61D44003A01B6 /* Debug */, + CCE96FD41BF61D44003A01B6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = CCE96FC11BF61D44003A01B6 /* Project object */; +} diff --git a/NYAlertViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/NYAlertViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..e83b021 --- /dev/null +++ b/NYAlertViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/NYAlertViewController.xcodeproj/xcshareddata/xcschemes/NYAlertViewController.xcscheme b/NYAlertViewController.xcodeproj/xcshareddata/xcschemes/NYAlertViewController.xcscheme new file mode 100644 index 0000000..29f65f5 --- /dev/null +++ b/NYAlertViewController.xcodeproj/xcshareddata/xcschemes/NYAlertViewController.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NYAlertViewController/Info.plist b/NYAlertViewController/Info.plist new file mode 100644 index 0000000..1b65e63 --- /dev/null +++ b/NYAlertViewController/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSHumanReadableCopyright + Copyright © 2015 Nealon Young. All rights reserved. + + diff --git a/NYAlertViewController/NYAlertView.m b/NYAlertViewController/NYAlertView.m index 227d52f..59e22cd 100644 --- a/NYAlertViewController/NYAlertView.m +++ b/NYAlertViewController/NYAlertView.m @@ -338,7 +338,7 @@ - (instancetype)initWithFrame:(CGRect)frame { metrics:nil views:NSDictionaryOfVariableBindings(_contentViewContainerView)]]; - [self.alertBackgroundView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_textFieldContainerView]|" + [self.alertBackgroundView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[_textFieldContainerView]-10-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_textFieldContainerView)]]; @@ -348,7 +348,7 @@ - (instancetype)initWithFrame:(CGRect)frame { metrics:nil views:NSDictionaryOfVariableBindings(_actionButtonContainerView)]]; - [self.alertBackgroundView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[_titleLabel]-2-[_messageTextView][_contentViewContainerView][_textFieldContainerView][_actionButtonContainerView]-|" + [self.alertBackgroundView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-10-[_titleLabel]-2-[_messageTextView][_contentViewContainerView][_textFieldContainerView]-10-[_actionButtonContainerView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_titleLabel, diff --git a/NYAlertViewController/NYAlertViewController.m b/NYAlertViewController/NYAlertViewController.m index 7d3e8ab..aba36cb 100644 --- a/NYAlertViewController/NYAlertViewController.m +++ b/NYAlertViewController/NYAlertViewController.m @@ -524,6 +524,8 @@ - (void)createActionButtons { - (void)actionButtonPressed:(UIButton *)button { NYAlertAction *action = self.actions[button.tag]; action.handler(action); + + [self dismissViewControllerAnimated:YES completion:nil]; } #pragma mark - Getters/Setters diff --git a/NYAlertViewControllerDemo/NYAlertViewDemo/DemoViewController.m b/NYAlertViewControllerDemo/NYAlertViewDemo/DemoViewController.m index d0d317b..5da3613 100644 --- a/NYAlertViewControllerDemo/NYAlertViewDemo/DemoViewController.m +++ b/NYAlertViewControllerDemo/NYAlertViewDemo/DemoViewController.m @@ -50,13 +50,13 @@ - (void)showStandardAlertView { [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Destroy", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; [self presentViewController:alertController animated:YES completion:nil]; @@ -88,7 +88,7 @@ - (void)showCustomAlertViewWithActionCount:(NSInteger)actionCount { } [alertViewController addAction:[NYAlertAction actionWithTitle:actionTitle style:actionStyle handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; } @@ -108,7 +108,7 @@ - (void)showTextFieldAlertView { NYAlertAction *submitAction = [NYAlertAction actionWithTitle:NSLocalizedString(@"Submit", nil) style:UIAlertActionStyleDefault handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]; submitAction.enabled = NO; [alertViewController addAction:submitAction]; @@ -127,7 +127,7 @@ - (void)showTextFieldAlertView { [alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; [alertViewController addTextFieldWithConfigurationHandler:^(UITextField *textField) { @@ -150,13 +150,13 @@ - (void)showMapViewAlertView { [alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Delete", nil) style:UIAlertActionStyleDestructive handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; [alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; alertViewController.title = NSLocalizedString(@"Content View", nil); @@ -198,13 +198,13 @@ - (void)showDatePickerAlertView { [alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Select", nil) style:UIAlertActionStyleDefault handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; [alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; UIDatePicker *datePicker = [[UIDatePicker alloc] init]; @@ -224,7 +224,7 @@ - (void)showLongMessageAlertView { [alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; [self presentViewController:alertViewController animated:YES completion:nil]; @@ -262,13 +262,13 @@ - (void)showCustomUIAlertView { [alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Ok", nil) style:UIAlertActionStyleDefault handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; [alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(NYAlertAction *action) { - [self dismissViewControllerAnimated:YES completion:nil]; + }]]; [self presentViewController:alertViewController animated:YES completion:nil];