Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated code for ARC, updated view property and set timer completion to remove. #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iToast.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef enum {
NSString *text;
}

- (void) show;
- (void) show;
- (void) show:(iToastType) type;
- (iToast *) setDuration:(NSInteger ) duration;
- (iToast *) setGravity:(iToastGravity) gravity
Expand Down
13 changes: 6 additions & 7 deletions iToast.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ - (void) show:(iToastType) type {
lbfrm.origin.y = ceil(lbfrm.origin.y);
label.frame = lbfrm;
[v addSubview:label];
[label release];


if (image) {
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = [self _frameForImage:type inToastFrame:v.frame];
[v addSubview:imageView];
[imageView release];

}

v.backgroundColor = [UIColor colorWithRed:theSettings.bgRed green:theSettings.bgGreen blue:theSettings.bgBlue alpha:theSettings.bgAlpha];
Expand Down Expand Up @@ -224,14 +224,15 @@ - (void) show:(iToastType) type {
v.center = point;
v.frame = CGRectIntegral(v.frame);

NSTimer *timer1 = [NSTimer timerWithTimeInterval:((float)theSettings.duration)/1000
target:self selector:@selector(hideToast:)
NSTimer *timer1 = [NSTimer timerWithTimeInterval:((float)theSettings.duration)/1000
target:self selector:@selector(removeToast:)
userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:timer1 forMode:NSDefaultRunLoopMode];

v.tag = CURRENT_TOAST_TAG;

UIView *currentToast = [window viewWithTag:CURRENT_TOAST_TAG];
view = v;
if (currentToast != nil) {
[currentToast removeFromSuperview];
}
Expand All @@ -242,8 +243,6 @@ - (void) show:(iToastType) type {
v.alpha = 1;
[UIView commitAnimations];

view = [v retain];

[v addTarget:self action:@selector(hideToast:) forControlEvents:UIControlEventTouchDown];
}

Expand Down Expand Up @@ -307,7 +306,7 @@ - (void) removeToast:(NSTimer*)theTimer{


+ (iToast *) makeText:(NSString *) _text{
iToast *toast = [[[iToast alloc] initWithText:_text] autorelease];
iToast *toast = [[iToast alloc] initWithText:_text];

return toast;
}
Expand Down