Giter Club home page Giter Club logo

toast's People

Contributors

aceisscope avatar alexruperez avatar ayanonagon avatar cjsliuj avatar hakanw avatar ilg avatar lifeofbrian avatar natashatherobot avatar phamquy avatar scalessec avatar stephenwakely 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  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

toast's Issues

Add support for customizable defaults (eg. make view alpha configurable)

The way the code is currently written, if you show a toast, it will always be completely opaque -- the alpha is always 1.

Originally, I thought passing in the alpha value might be a good way to do it, but there are some other values that might be nice to configure (basically, many of the static const values). It might be nice to add support to customize these values.

I thought of a few ways this could be done. The easiest might be to read from UserDefaults to see if there is a value to use instead of the hardcoded value. If not, it uses the original value.

Toast disappears behind Tab Bar

The default toast (bottom) is hidden behind the tab bar when calling it from a TableViewController inside a NavigationController inside a TabBarController (other configurations not tested).

Please put toast in queue

I 'd like you to put toast in queue and toast could show out one by one. I want to only show one toast at one time in my app but now, the toast need time to dismiss and may two toast appears and overlap . Need your help~~~~
Thanks.

Size calculation is incorrect when number of lines != 0

To reproduce:

  1. Set the messageNumberOfLines to 1.
  2. Call makeToast: a long message.

Result:
The makeToast wrapper view is sized to the full message length, regardless of the number of lines.

To fix:
We should use sizeThatFits: on the labels and remove the cs_sizeForString: helper method completely.

This is also affecting titleNumberOfLines.

using deprecated method

'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

The pop-up message is like a timer.

My English is not very good, the problem is: when the user interacts with the interface several times showtoash, it will always show the message will not stop, I would like to have a history of the destruction of the news, and then show the information now.

我的英语不是很好,问题是:当用户与界面交互多次 showtoash,它将始终显示消息 不会停止,我想有一个销毁历史消息,显示现在信息。

Warnings regarding __bridge casts when not using ARC

I've got 3 warnings when using your library and not using ARC:

Toast+UIView.m:97:49: '__bridge' casts have no effect when not using ARC
Toast+UIView.m:171:32: '__bridge' casts have no effect when not using ARC
Toast+UIView.m:178:54: '__bridge' casts have no effect when not using ARC

Toast's title is not alignment center

Hello, i work on iOS 8.1 and test on device.
Toast's title is not alignment center, please help me. Thanks advance!
Here is my code:

            [self.view makeToast:@"You've unlocked from level 16 to level 30!"
                        duration:4.0
                        position:CSToastPositionTop
                           title:@"Congratulations"];

Here is image:
Image of Yaktocat

Toast View Hide behind Keyboard

Hello All,
if i was validate my text field, any error are generate then i am display it on ToastView. as well as i was focus on that text field as well. so i am write down following code :

[textfield becomeFirstResponder];
[[[UIApplication sharedApplication] keyWindow] makeToast:InvalidPassword duration:3.0 position:@"bottom"];

but my toast view hide behind the keyboard. so how can i solve it. I am using Storyboard.

toast

Toast should extend UIWindow

Displaying a toast in a view which has scrollview cannot guarantee that it would appear where you expect it to be. Using the window's frame guarantees that positions will constant.

Add support for tabbed views

newish to github but here are the changes I made to support tabs.
Please make the following change to support tabbed views
add to top of .m
static const int TabBarHeight = 56; //standard height of the tab bar ios 7 +
in .m change centerPointForPosition to:

  • (CGPoint)centerPointForPosition:(id)point withToast:(UIView *)toast {
    if([point isKindOfClass:[NSString class]]) {
    // convert string literals @"top", @"bottom", @"center", @"bottom_tabbed", or any point wrapped in an NSValue object into a CGPoint
    if([point caseInsensitiveCompare:@"top"] == NSOrderedSame) {
    return CGPointMake(self.bounds.size.width/2, (toast.frame.size.height / 2) + CSToastVerticalPadding);
    } else if([point caseInsensitiveCompare:@"bottom"] == NSOrderedSame) {
    return CGPointMake(self.bounds.size.width/2, (self.bounds.size.height - (toast.frame.size.height / 2)) - CSToastVerticalPadding);
    } else if([point caseInsensitiveCompare:@"center"] == NSOrderedSame) {
    return CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2);
    } else if([point caseInsensitiveCompare:@"bottom_tabbed"] == NSOrderedSame){
    return CGPointMake(self.bounds.size.width/2, (self.bounds.size.height - (toast.frame.size.height / 2)) - CSToastVerticalPadding -TabBarHeight);
    }
    } else if ([point isKindOfClass:[NSValue class]]) {
    return [point CGPointValue];
    }

    NSLog(@"Warning: Invalid position for toast.");
    return [self centerPointForPosition:CSToastDefaultPosition withToast:toast];
    }

sizeWithFont is deprecated in iOS 7

sizeWithFont is deprecated in iOS 7. boundingRectWithSize is said to be a valid substitute though I can't get it to work.

NOTICE FOR "sizeWithFont":
'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

REPLACEMENT CODE ACCORDING TO APPLE:
// size the title label according to the length of the text
CGSize maxSizeTitle = CGSizeMake((self.bounds.size.width * CSToastMaxWidth) - imageWidth, self.bounds.size.height * CSToastMaxHeight);
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = titleLabel.lineBreakMode;
CGSize expectedSizeTitle = [title boundingRectWithSize:maxSizeTitle
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:titleLabel.font, NSParagraphStyleAttributeName:paragraphStyle.copy}
context:nil].size;
titleLabel.frame = CGRectMake(0.0, 0.0, expectedSizeTitle.width, expectedSizeTitle.height);

RESULT WITH REPLACEMENT CODE
Image of small dot displaying issue with boundingRectWithSize

As seen above the replacement is not sizing correctly. If you have time, please look into this. I do not think it is very hard to fix but I do not have the time myself :(

Thanks for an otherwise great code 👍

Show without view controller?

Love it! Easy, works great, thanks!

One great thing about Toasts on Android is that they show even if your activity is finished. Can you think of a way to do that with your iPhone Toast code? If I use [self makeToast], where self is a UIViewController, the toast won't show if I immediately pop the view controller. Any ideas?

Add NSTimer to main run loop.

Not a bug, just an improvement:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:duration target:self selector:@selector(toastTimerDidFinish:) userInfo:toast repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

A possible enhancement!

Hello,
Is it possible to add a cancel/dismiss button in order not to dismiss toast by timer but with button?
Thanks for your nice tool.

George Gerardis

Position not honored when making a toast in a UIWindow

For example, if using an iPad in landscape and making a toast:

[self.window makeToast:message duration:duration position:position];

The toast will always be at the physical bottom of the device (i.e. above the home button), regardless of the position parameter.

Text alignment is broken

As mention in #53, if the title or message is shorter than the width of the wrapper view, it does not appear to be centered.

Version compatibility issues

Toast/Toast/Toast/Toast+UIView.m:237:20: 'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

maybe fix it

Toast-specific hidesOnTap Toggle

I want some toasts in my app to respond to user taps and some to ignore user taps. Currently, the CSToastHidesOnTap is a global static const, so I don't think I can set it on a toast-by-toast basis, can I? I think I'll have to turn this into a UIView subclass and add a @property hidesOnTap.

I'm just checking that there isn't some use of the static const that I'm missing before I stray from the UIView category paradigm.

how to import it in swift

I'm a new baby to IOS dev,I don't know how to use it in swift project.
is like this?

import UIView+Toast

bad access

If I switch to another screen with visible toast, exc_bad_access happens in animationDidStop. On line UIView *toast = (UIView *)(__bridge id)context;

Feature request: [Toast makeToast:@"something"];

For now, the only way to toast is to call it from a specific view.

[someView makeToast:@"oops"];

But what if we don't care about the view, what if we just want to display a toast right away regardless of where we are. Like:

[Toast makeToast:@"oops"];

What do you think about this? Are we going to implement it in the future?

Rotation Issues

The Toast view doesn't appear to work well when the device orientation is changed. If the Toast view is centered for example and while it's being displayed, the device is rotated, the Toast view doesn't remain centered.

Multiple toasts get overlaid on top of each other

Tried calling hideToastActivity but doesn't seem to find the toast view
EDIT: realize that's for the spinner. Doesn't seem to be a method for hiding the toast manually before loading another one, plus seems to make sense to hide any that are still visible automatically.

Example:
ios simulator screen shot feb 16 2014 5 43 52 pm

I can't make it work on SDK 6.1

It works like a charm when I compile it with SDK 7

But when I try to do it with the 6.1 I get the following error on UIView+Toast.m

CGRect boundingRect = [string boundingRectWithSize:constrainedSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil];

ERROR : No visible @interface for 'NSString' declares the selector 'boundingRectWithSize:options:attributes:context:'

Does it work with SDK 6.1? or just with 7?

Finallly , just to give more details, I have installed manually so I have copied the .m and .h and I have made sure that the Quartzcore.framework is added.

http://postimg.org/image/tj66076if/

Enabled touch gesture to hide popup

I have downloaded this popup and love it. What I don't like is that it auto hides it after 3 secs. Is there a way I can enable touch gesture so that when a user touches the popup it hides it only then?

I have been banging my head left and right and can't figure out. I tried this and this doesn't work.

  • (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position title:(NSString *)title {

    NSLog(@"inside here ...");

    UIView *toast = [self viewForMessage:message title:title image:nil];

    UIGestureRecognizer *gesture;
    gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:toast:)];
    [self addGestureRecognizer:gesture];

    [self showToast:toast duration:interval position:position];
    }

  • (void)handleTap:(UIView *)toast:(UIPanGestureRecognizer *)gesture
    {
    NSLog(@"handleTap ....");

    [toast removeFromSuperview];
    }

Add callback block to makeToast

It would be good to have a onCompleted block or similar, to know when the toast has been removed from the screen. Or at least some way of checking to see if the toast is still on screen to avoid overlap.

`- (void)makeToast:(NSString *)message ` can't show toast

- (void)makeToast:(NSString *)message can't show toast.
I have tried

[self.view makeToast:@"This is a piece of toast with a title."
                duration:3.0
                position:@"top"
                title:@"Toast Title"];

it works.

but

 [self.view makeToast:"Toast Title"];

it doesn't work

Need hide/clear Toast functions

When back to last ViewContoller , a toast view will still be shown in duration. So need hide or remove toast maked before .

UITextField Toast (Xcode7.2 ios9.2)

when I use "UITextField" keyboard show, the toast was covered by "keyboard"!
My test code as follows:


  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"test Toast";
    self.view.backgroundColor = [UIColor whiteColor];

    tt = [[UITextField alloc] init];
    tt.frame = CGRectMake(50, 100, 200, 40);
    tt.placeholder = @"UItoasttestWork";
    // tt.backgroundColor = [UIColor lightGrayColor];

    [self.view addSubview:tt];
    UIButton *toastBtn = [[UIButton alloc] init];
    toastBtn.frame =CGRectMake(255, 100, 60, 40);
    [toastBtn setTitle:@"Toast" forState:UIControlStateNormal];
    [toastBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [toastBtn addTarget:self action:@selector(zButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:toastBtn];

    UITapGestureRecognizer *tapGeser = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHidden:)];
    [self.view addGestureRecognizer:tapGeser];

}
-(void)zButtonClick:(UIButton *)btn{
[self.navigationController.view makeToast:@"This is a piece of toast"];
}


Any help will be appreciated!

Toast was outside the visible screen in a scrollview

I use the toast in a scrollview,like:[scrollView makeToas:@""];,
If the scrollView's contentSize is very large,maybe double size of screen, so if I scroll down to bottom and make toast, the toast will show outside the visible area.
Is there a way to locate the toast at a certain position on screen?

IOS7 - Toast under UINavigationBar

Hello,

When we show a toast at position TOP under IOS 7,
The toast is partially hidden by navigation bar.

Is there a way to fix this behavior ?

Thanks

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.