GithubHelp home page GithubHelp logo

uialertcontroller-blocks's People

Contributors

fedser avatar ryanmaxwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uialertcontroller-blocks's Issues

Getting crashes randomly with AlertController while presenting it on top of app window.

I am using the below code to set alert controller title, message and buttons (UIAlertController+Blocks)
+ (instancetype)showInViewController:(UIViewController *)viewController withTitle:(NSString *)title message:(NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles

Using below code to present the alertcontroller (UIAlertController+Window)

self.alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.alertWindow.rootViewController = [[UIViewController alloc] init]; self.alertWindow.tintColor = [UIApplication sharedApplication].delegate.window.tintColor; self.alertWindow.windowLevel = UIWindowLevelAlert + 1; [self.alertWindow makeKeyAndVisible]; [self.alertWindow.rootViewController presentViewController:self animated:animated completion:nil];

This crash occurs randomly. Below is the crash log reported in crashlytics.

Crashed: com.apple.main-thread
0 UIKit 0x1881fb788 sortByWindowLevel + 286
1 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
2 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
3 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
4 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
5 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
6 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
7 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
8 CoreFoundation 0x182260ac4 CFSortIndexes + 480
9 CoreFoundation 0x18226068c -[NSMutableArray sortRange:options:usingComparator:] + 380
10 CoreFoundation 0x182273e48 -[NSMutableArray sortUsingFunction:context:] + 116
11 UIKit 0x1881fb73c +[UIWindow allWindowsIncludingInternalWindows:onlyVisibleWindows:forScreen:] + 212
12 UIKit 0x188237dec -[UIViewController _window] + 304
13 UIKit 0x188523fd0 -[UIViewController _parentTraitEnvironment] + 264
14 UIKit 0x188524060 -[UIViewController traitCollection] + 60
15 UIKit 0x1881bde8c __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 408
16 UIKit 0x1881bdbe8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 792
17 UIKit 0x1881c9ad0 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1788
18 UIKit 0x1881c93bc -[UIView(Hierarchy) addSubview:] + 828
19 UIKit 0x1883427f4 -[UICollectionViewController loadView] + 1084
20 UIKit 0x1881c2074 -[UIViewController loadViewIfRequired] + 184
21 UIKit 0x1883423a0 -[UICollectionViewController collectionView] + 28
22 UIKit 0x18871ab4c -[_UIAlertControllerTextFieldViewController init] + 184
23 UIKit 0x188659360 _UIAlertControllerCommonInit + 416
24 UIKit 0x1886594b8 -[UIAlertController initWithNibName:bundle:] + 104
25 UIKit 0x188659534 +[UIAlertController alertControllerWithTitle:message:preferredStyle:] + 100
26 app_name 0x100455b7c +[UIAlertController(Blocks) showInViewController:withTitle:message:preferredStyle:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:popoverPresentationControllerBlock:tapBlock:] (UIAlertController+Blocks.m:47)
27 app_name 0x10045631c +[UIAlertController(Blocks) showAlertInViewController:withTitle:message:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:tapBlock:] (UIAlertController+Blocks.m:106)
28 app_name 0x1000d48f0 -[class_name textField:shouldChangeCharactersInRange:replacementString:]

Cocoapod for swift

Please add to your documentation that for Swift it should be imported like

import UIAlertController_Blocks

I will crash showAlertController on viewController is another presentViewController

in metthod
+ (instancetype)showInViewController:(UIViewController *)viewController withTitle:(NSString *)title message:(NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles popoverPresentationControllerBlock:(void(^)(UIPopoverPresentationController *popover))popoverPresentationControllerBlock tapBlock:(UIAlertControllerCompletionBlock)tapBlock {

I'm add this code it will worked

UIWindow *alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *vc = [[UIViewController alloc] init];
alertWindow.rootViewController = vc;
[alertWindow makeKeyAndVisible];
[alertWindow.rootViewController presentViewController:controller animated:YES completion:nil];

There's a bug in +(instancetype)showInViewController:withTitle:message:preferredStyle:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:tapBlock:

At the beginning of this method you create a UIAlertController and save a weak reference to it. Since there is no strong reference to it, the generated code can (and does) immediately release the UIAlertController and nil out the pointer stored in the weak reference "controller". I'm not sure why it doesn't happen to you, but it certainly happens and is fully reproducible in a project that I contribute to that includes your library.

A reasonable fix is to assign the return value to a strong reference, and then copy it to your weak reference.

I didn't look for other such cases in the code, but you might wish to.

Run-time error - no location information for UIModalPresentationPopover

Put this code in my iPad app (XCode 6.1, iOS 8.1.1, Ojbective-c) to replace existing deprecated UIActionSheet and got this run-time error:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x7fdfe3324f00>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
This is my code:
[UIAlertController showActionSheetInViewController:self withTitle:@"Test Action Sheet" message:NSLocalizedString(@"Are you sure you want to delete ALL appointments?",nil) cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Yes" otherButtonTitles:@[@"No"] // same as Cancel tapBlock:^(UIAlertController *controller, UIAlertAction *action, NSInteger buttonIndex){ if (buttonIndex == UIAlertControllerBlocksCancelButtonIndex) { NSLog(@"Cancel Tapped"); } else if (buttonIndex == UIAlertControllerBlocksDestructiveButtonIndex) { NSLog(@"Delete Tapped"); } else if (buttonIndex >= UIAlertControllerBlocksFirstOtherButtonIndex) { NSLog(@"Other Action Index %ld", (long)buttonIndex - UIAlertControllerBlocksFirstOtherButtonIndex); } }];

None of your examples show anything that would correct this issue. Can you advise how to correct this?

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.