dogo / sclalertview Goto Github PK
View Code? Open in Web Editor NEWBeautiful animated Alert View. Written in Objective-C
License: MIT License
Beautiful animated Alert View. Written in Objective-C
License: MIT License
I tried using this on one of my apps. It works well in UIViewController but got some issue in location when implementing in UITableViewController. What I did was I modified SCLAlertView.m and set the _backgroundView.frame to CGRectMake(0[x],0[y],vcWidth[width], vcHeight[as height]);. This is just a workaround not sure if you got a better solution. Thanks by the way for this awesome class:)
thanks.
It would be useful to have to ability to add a tickbox to the alertview allowing the user to select "don't show this again". Ideally with blocks:
//Using Blocks With Validation
[alert addTickbox:@"Don't show again" validationBlock:^BOOL {
BOOL tickboxValue = ....
return tickboxValue;
} actionBlock:^{
// handle successful validation here
}];
I can't seem to be able to apply the fade duration to the default 'Done, 'OK' default button. Whatever I do, I just get an immediate removal from the superview.
Any ideas?
Can i write the code anywhere,not limit to viewController?
i just find the method to add alert view must have a parameter that is viewController's object.
testing now on simulator for iPhone6.
Run demo app
Choose Show Edit
tap in the textfield. Keyboard appears and the control moves up.
Rotate simulator. The keyboard rotates and hides textfield.
Close the keyboard and you will see the control move downwards to compensate for the
keyboard removal.
thanks for the control by the way ๐
SCLAlertView.m line 520,
Change from:
NSAttributedString *str =[[NSAttributedString alloc] initWithString:subTitle];
To:
NSAttributedString *str =[[NSAttributedString alloc] initWithString:subTitle attributes:attr];
It can apply the "attr" you have defined.
Thank you for your nice code.
its slow can when it first run
better on second,
can you plz make it faster
Hi, there's an issue with the control is you try to call it from a side menu or "drawer".
I'm using MFSideMenu and when I call SCLAlertView from the open side menu, the shadow only covers the side view controller's view and the actual alert is displayed off-center.
Hopefully there's an easy way to add in the ability to display the alert in the middle of the window as opposed to the view controller's view. Let me know if I can be of help. I didn't have a lot of time to work on it today, but will check it out another day!
It's an awesome replacement for UIAlertView, I would love to use it!!
Thank you for the nice Alert Controller.
When I try to show the alert under PickerView delegate, like the following:
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
// if something true I will give a warning to the user
[alert showWarning....];
}
The UIAlertView works under such condition but not SCLAlertView, it displays on the very top of my tableview(should be on top of the pickerView like UIAlertView ), so I see very strange things like the alertView is transparent to the parent view and the PickerView background visible far below ( pickerView is located at the bottom of a long list static tableview cells)
Hi, what is the best way to change title font size (we work with multiples computers and using cocoapods, if I customize the root files, its a problem in another computer)
Thanks.
how i can add a textarea in the alert
Every time the user switches keyboards (i.e. keyboard extensions), the alert will move upwards and not position itself correctly.
upd:
I found scrolling!
But user's window resizing still needed feature as option.
The alert will display off-centered if showed from a modal presented in form sheet style on the iPad.
When implementing two different UIKeyboardType on two UITextField, swapping focus between those UITextFields will cause the alert view to be pushed further up and did not reset back to center screen.
Reason is the boundingRectWithSize call in SCLAlertView.m has to be done on a NSAttributedString object for iOS 6 instead of NSString for iOS7.
A conditional statement makes the trick:
// Adjust text view size, if necessary
CGSize sz = CGSizeMake(kWindowWidth - 24.0f, 90.0f);
NSDictionary *attr = @{NSFontAttributeName:self.viewText.font};
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){
NSString *str = subTitle;
CGRect r = [str boundingRectWithSize:sz options:NSStringDrawingUsesLineFragmentOrigin attributes:attr context:nil];
CGFloat ht = ceil(r.size.height) + 10;
if (ht < kTextHeight)
{
kWindowHeight -= (kTextHeight - ht);
kTextHeight = ht;
}
} else {
NSAttributedString *str =[[NSAttributedString alloc] initWithString:subTitle];
CGRect r = [str boundingRectWithSize:sz options:NSStringDrawingUsesLineFragmentOrigin context:nil];
CGFloat ht = ceil(r.size.height) + 10;
if (ht < kTextHeight)
{
kWindowHeight -= (kTextHeight - ht);
kTextHeight = ht;
}
}
see the title.
Hi!
Great looking alertview!
But whatever showAnimationType I try to set It always shows as FadeIn.
The hideAnimationType is working correctly though.
Tested on simulator with 7.1 and device with 8.0.2
If I show an alert with some long text, the end is truncated.
Is it possible to either shrink the text size more when needed or preferably expand the height of the alert view to fit the text?
Thanks for this awesome work.
Is it possible to add an image to the AlertView?
Thanks!
I noticed that the SCAlertView is pushed to the lower left side of the screen if displayed on an iPhone 4S while in landscape orientation. Other size displays also cause parts of the popup to be hidden off screen.
I was running some tests with the components, and I noticed it doesn't seem to rotate on an iPad using
7.0.4
IPad 3
When it runs in the simulator it works fine, but on the actual device it fails. The tests were performed using the test app. I have included an image from the iPad.
I also noticed if I run it in Landscape on my iPhone 5 with the same OS version it too displays the alert in portrait, even while the device is landscape.
Any suggestions?
Awesome work.
If an alert with a UITextField triggers another alert (any type), it will move from the center of the view to the bottom when the keyboard disappears. I've provided an example below:
SCLAlertView *alert = [[SCLAlertView alloc] init];
UITextField *textField = [alert addTextField:@"Text Field"];
[alert addButton:@"Done" actionBlock:^(void) {
// Executed when "Done" is pressed.
if ([*condition goes here*]) {
SCLAlertView *alert2 = [[SCLAlertView alloc] init];
alert2.shouldDismissOnTapOutside = YES;
[alert2 showCustom:self
image:[UIImage imageNamed:@"Image Name"]
color:[UIColor flatMagentaColor]
title:@"Title 2"
subTitle:@"Subtitle 2"
closeButtonTitle:@"Close 2"
duration:0.0f];
// At this point the keyboard would disappear and the alert would slide down to the bottom of the view with it.
} else {
// Go about your normal business and no bugs appear
}
}];
[alert showEdit:self
title:@"Title"
subTitle:@"Subtitle"
closeButtonTitle:@"Close"
duration:0.0f];
How detect when the user press a button?
Since the introduction of the textContainer definition in SCLAlertView.m which are iOS>7, the app crashes on iOS6.x
_viewText.textContainerInset = UIEdgeInsetsZero;
_viewText.textContainer.lineFragmentPadding = 0;
I could comment these 2 lines, but then the text appears truncated by the button. Any recommendation to workaround the issue?
how i can make the background transparent,
i mean the dark overlay,
how i can remove it
can you plz add a way or option to only show the alert one if there an alert appear,
even if the user trigger an alert
When SCLAlertView is using with other libraries via cocoapods name ValidationBlock is conflicted. Can you add prefix SCL to it as you did for SCLActionBLock? Thus SCLValidationBlock will be unique.
I'm having an issue with this.
I'm a big fan of SCLAlertView but i'm having an issue with a section within my code.
I am using the code elsewhere in my project but when using it within another view controller I'm receiving the above error.
It is showing itself within UIImage+ImageEffects.m on line [keyWindow.layer renderInContext:context]; within
This is the code I am using to call the alert
SCLAlertView *alert = [[SCLAlertView alloc] init];
UITextField *textField = [alert addTextField:@"Quantity"];
[textField setKeyboardType:UIKeyboardTypeNumberPad];
alert.backgroundType = Blur;
alert.shouldDismissOnTapOutside = YES;
[alert showSuccess:self title:@"Quantity" subTitle:@"Enter Quantity" closeButtonTitle:@"Done" duration:0.0f];
Thanks in advance
Edit: If i leave the alert view standard it works perfectly. It only seems to have an issue when customising the alert where it crashes
SCLAlertView *alert = [[SCLAlertView alloc] init];
UITextField *textField = [alert addTextField:@"Quantity"];
[textField setKeyboardType:UIKeyboardTypeNumberPad];
alert.backgroundType = Blur;
[alert showSuccess:self title:@"Quantity" subTitle:@"Enter Quantity" closeButtonTitle:@"Done" duration:0.0f];
That works fine
Hi! Nice alert view. But I have an issue on rotating with showed keyboard. Seems, coords calculation is not correct. I use it on iPhone.
Is there any way to do it?
When triggering the Alert (which is btw absolutely great) in a TableView, when the tableview is scrolled to the very bottom, the positioning of the alert gets sometimes even out of screen and a weird background effect occurs (see screenshot)... Resigning the first responder and putting the focus back to a textfield which is at the beginning of the tableview doesn't help...
It would be great to have progress dialog too. I can imagine it as determinate/infinite loop in icon place with text.
can i specify a uicolor for it,
modifying the UIColor *viewColor; i mean
While using other libraries with cocoapods, I've found out the name ActionBlock is conflicted with others. Would you consider adding Prefix to the typedef? like (^ActionBlock)(void) to something like (^SCLActionBLock)(void). Just my 2 cents. Thank you for the great control.
Hello,
great AlertView! I am just implementing it in my Apps! However, I would like to show alert sometimes without SubTitle. How can I do it, without leaving a large space between Title and the button? To avoid the wasted space, would be great if this can be done/enhanced!
Many Thanks and regards
-Jan
Hi,
I got to say that i love SCLAlertView! I have ran into one problem though:
On some views the alert does not show up in the center of the view (see this screenshot: https://drive.google.com/a/socialbrothers.nl/file/d/0B6NlCTs3hnXlems4c1dueE9vMDA/view?usp=sharing )
Any thoughts on how to correct the position?
Oh i call in the Custom AlertView from a UIBarbuttonItem to add a object to the users calendar (nothing strange)
When you have an alert shown, and the back button is clicked to take the User back to the parent view, the entire view controller stays in memory and never goes away. The way you can test this in simulator is to print a line in your deinit or didReceiveMemoryWarning for the child view. You'll notice that child views that pop back to root without an alert shown will deinit, and a line will not print when you didReceiveMemoryWarning. In contrast, if you have a child view with an alert shown and hit back, you will not see the deinit line and didReceiveMemoryWarning will print a line for that child view.
deinit {
NSLog("deinit \(self)")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
NSLog("didReceiveMemoryWarning \(self)")
}
i find ,when i click the button, it shows no status changed, i mean the appereance.
Hey Diogo, I'm integrating this using Cocoapods into a new app, and after adding it to my podfile and running pod install
everything was pulled in correctly, but did not include the recent changes (validation block) that you merged. Is there an easy way to fix that?
I can compile great but not in release mode (making an archive for ad-hoc distribution), the compiler says modules are disabled. Do I have a config issue?
"use of '@import' when modules disabled"
I've enjoyed working with your repo! Here's a small issue I encountered.
I have a main ViewController that is embedded in a UINavigationController. On that main view, I show an SCLAlertView, using:
SCLAlertView *alert = [[SCLAlertView alloc] init];
[alert showSuccess:self.navigationController title:@"Title" subTitle:@"Text" closeButtonTitle:nil duration:2.0f];
For the root view controller, I use self.navigationController
because I want the SCLAlert's shadow view to cover the title bar and buttons.
Now here comes the issue.
From that view, I present a modal view controller. When I dismiss that window the main view pushes a blank view controller for some reason. This ONLY happens if I've displayed the SCLAlert, THEN display the modal. It doesn't happen if I haven't displayed the SCLAlert before displaying the modal view controller.
I don't believe that it is possible to change the color of the alert when it contains a UITextField. Maybe it could be changed to a format like that of adding another button, that way a custom alert could be set up and then a UITextField added.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.