Giter VIP home page Giter VIP logo

gcdiscreetnotificationview's Introduction

GCDiscreetNotificationView

GCDiscreetNotificationView is a discreet, non-modal, notification view for iOS. You can use it to show an activity or state of you app without blocking the user interactions.

GCDiscreetNotificationView features:

  • Easy to use : init and show
  • Can show an activity indicator
  • Two presentation mode (top and bottom)
  • All properties (text, activity and presentation mode) can be changed in a animated fashion

Usage

(See the demo project included)

You simply allocate the notification view with one of the following methods.

The parameters are the following :

  • text : the text presented on the notification
  • activity : if set to YES, the notification with show a activity indicator
  • aPresentationMode : the presentation mode of the notification (top or bottom)
  • aView : the view that will contain the notification. The view should be able to accept subviews (will not work on a UITableView for example)
- (id) initWithText:(NSString *)text inView:(UIView *)aView;
- (id) initWithText:(NSString *)text showActivity:(BOOL)activity inView:(UIView *)aView;
- (id) initWithText:(NSString *)text showActivity:(BOOL)activity inPresentationMode:(GCDiscreetNotificationViewPresentationMode) aPresentationMode inView:(UIView *)aView;

You show or hide the notification with these methods. The showAndDismissAutomaticallyAnimated will hide your notification automatically after 1 second.

- (void) showAnimated;
- (void) hideAnimated;
- (void) hideAnimatedAfter:(NSTimeInterval) timeInterval;
- (void) show:(BOOL) animated;
- (void) hide:(BOOL) animated;
- (void) showAndDismissAutomaticallyAnimated;
- (void) showAndDismissAfter:(NSTimeInterval) timeInterval;

You can change the text of the label of the activity viewing at any moment with these properties.

@property (nonatomic, assign) UIView *view;
@property (nonatomic, assign) GCDiscreetNotificationViewPresentationMode presentationMode;
@property (nonatomic, copy) NSString* textLabel;
@property (nonatomic, assign) BOOL showActivity;

These properties can be changed in a animated fashion (except the view).

- (void) setTextLabel:(NSString *) aText animated:(BOOL) animated;
- (void) setShowActivity:(BOOL) activity animated:(BOOL) animated;
- (void) setTextLabel:(NSString *)aText andSetShowActivity:(BOOL)activity animated:(BOOL)animated;
- (void) setPresentationMode:(GCDiscreetNotificationViewPresentationMode) newPresentationMode animated:(BOOL) animated;

You can access directly the notification’s label and activity indicator. And change some propreties on that label and activity indicator. If you want to change the label’s text or hide the indicator, use textLabel or showActivity instead.

@property (nonatomic, retain, readonly) UILabel *label;  
@property (nonatomic, retain, readonly) UIActivityIndicatorView *activityIndicator;

gcdiscreetnotificationview's People

Contributors

bradsokol avatar dlinsin avatar enovav avatar gcamp avatar kgn avatar msmmaldonado 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

gcdiscreetnotificationview's Issues

Problems on iPhone 3G with iOS 4.2.1

I have a problem with iOS 4.2.1, I reproduced it on an iPhone 3G, but only in Adhoc builds. Debugging on iPhone 3G works as expected. Unfortunately, I don't have another device with that version, but I assume it's iPhone 3G only.

Here's my code

// in .h
GCDiscreetNotificationView *label;

// in .m
[self.label setTextLabel:@"Loading..." andSetShowActivity:YES animated:YES];

// after loading
self.label setTextLabel:[self lastUpdate] andSetShowActivity:NO animated:YES];

Now the result of running this on an iPhone 4 or iPhone 3GS is a first

"[Spinner] Loading..."

and later

"Last update 03.04.11" without any spinner

On an iPhone 3G the result is

"[Spinner] Loading..."

and later

"L" without any spinner

Somehow the label is cut off. I tried all day to find out what's going on, but I had to implement a nasty device specific workaround. Maybe you can help.

UIActivityIndicator not shown

When switching showActivity from YES to NO and then back to YES, it doesn't display the UIActivityIndicator. My workaround is to have to instances of GCDiscreetNotificationView, however looking at the code I think it should be possible to switch from YES to NO and back?

Crashes

Hello,

I seem to be getting odd crashes when using the 4.3 SDK:

2011-06-27 15:04:38.347 App[6726:307] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [0 0; nan 30]'
*** Call stack at first throw:
(
0 CoreFoundation 0x016e95a9 exceptionPreprocess + 185
1 libobjc.A.dylib 0x0183d313 objc_exception_throw + 44
2 CoreFoundation 0x016a1ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x016a1e6a +[NSException raise:format:] + 58
4 QuartzCore 0x0087fe3a _ZL16CALayerSetBoundsP7CALayerRKN2CA4RectEb + 227
5 QuartzCore 0x0088010a -[CALayer setBounds:] + 122
6 UIKit 0x009710e0 -[UIView(Geometry) setBounds:] + 394
7 App 0x00015194 -[GCDiscreetNotificationView layoutSubviews] + 654
8 QuartzCore 0x00877a5a -[CALayer layoutSublayers] + 181
9 QuartzCore 0x00879ddc CALayerLayoutIfNeeded + 220
10 QuartzCore 0x0081f0b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
11 QuartzCore 0x00820294 _ZN2CA11Transaction6commitEv + 292
12 QuartzCore 0x0082046d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
13 CoreFoundation 0x016ca89b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 27
14 CoreFoundation 0x0165f6e7 __CFRunLoopDoObservers + 295
15 CoreFoundation 0x016281d7 __CFRunLoopRun + 1575
16 CoreFoundation 0x01627840 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x01627761 CFRunLoopRunInMode + 97
18 GraphicsServices 0x01e1a1c4 GSEventRunModal + 217
19 GraphicsServices 0x01e1a289 GSEventRun + 115
20 UIKit 0x00949c93 UIApplicationMain + 1160
21 App 0x00002c93 main + 85
22 App 0x00002c35 start + 53
)
terminate called after throwing an instance of 'NSException'

It seems to be caused by your class? It crashes on both the iPhone and iPad simulator.

Support for device rotation

Hi, great work on this.

But I have been a little disappointed to see that the notification's frame isn't changed upon device rotation.
Would be a great thing to think about.

Position discreet view outside of the given view

Whereas discreet view will position it self "inside" the given view (both top and bottom positioning), I believe it could be sweet if we could set a property to put it "outside".

Say, you'd init as [[GCDiscreetNotificationView alloc] initWithText:@"Hello" inView:self.tabBarController.tabBar] or [[GCDiscreetNotificationView alloc] initWithText:@"Hello" inView:self.navigationController.navigationBar]; currently there's no way to overlay on self.view, because discreet view would appear either "inside" the tabBar or the navigationBar. One might try to [[GCDiscreetNotificationView alloc] initWithText:@"Hello" inView:self.view] instead, but if self.view is a scrollable view (e.g. an UITableView discreet view will scroll up and down.

I know this behaviour is documented in the README, but still I believe it should be only a matter of frame.origin positioning.

UITableViewController

Does the same thing as with tableView also apply with UITableViewControllers view?
If so, is there any workaround t use this library within a UITableViewController?

Notification not always displaying text

I wrote this function as a way of reproducing the issue. If you try to "show" a notification while the previous notification is in the process of hiding, it will not display the message on the second time around.

This problem appears when the user has many notifications within a short amount of time.

 - (void) notification{
     [self.notificationView setTextLabel:@"message displayed"];
     [self.notificationView show:YES];
     [self.notificationView hideAnimatedAfter:1.0f];
     [NSTimer scheduledTimerWithTimeInterval:1.0f
                                      target:self
                                    selector: @selector(notification)
                                    userInfo:nil
                                     repeats:NO];
 }

iOS Simulator Screen shot Feb 21 2013 7 18 48 PM

Clickable notification view?

Hello there, I needed the notification view to be clickable, so i've made some changes for my own app. If you agree it may be useful for others, i can send you a pull request. (I haven't forked yet from github..)

needs bringSubviewToFront

A call to bringSubviewToFront should be added in the show method, because the original layout
could be different from the one at initialization time.

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.