Loading ToolBar
Bonsoir tout le monde.
Voilà je pense que ça intéressera les débutants (j'espère en tout cas). Il y avait Eagle qui avait posté un LoadingView qui prenant tout l'écran de l'iphone.
Pour ma part après avoir vu une vidéo de la WWDC 21010 où le mec disait en gros qu'il fallait laisser l'user avoir la main libre sur l'UI et ne pas afficher des truc type UIAlertView etc ... je me suis dit qu'une UIToolBar à la Mail.app serait plus sympa pour mes applications.
Je viens de pondre le code donc si vous avez des améliorations, des remarques, etc ... n'hésitez pas
LoadingToolBar.h
LoadingToolBar.m
Pour l'utiliser c'est tout simple. Par exemple dans un UITableViewController :
.h
.m
J'espère que ça vous servira !
Voilà je pense que ça intéressera les débutants (j'espère en tout cas). Il y avait Eagle qui avait posté un LoadingView qui prenant tout l'écran de l'iphone.
Pour ma part après avoir vu une vidéo de la WWDC 21010 où le mec disait en gros qu'il fallait laisser l'user avoir la main libre sur l'UI et ne pas afficher des truc type UIAlertView etc ... je me suis dit qu'une UIToolBar à la Mail.app serait plus sympa pour mes applications.
Je viens de pondre le code donc si vous avez des améliorations, des remarques, etc ... n'hésitez pas

LoadingToolBar.h
<br />#import <Foundation/Foundation.h><br /><br /><br />@protocol RefreshDelegate<br />-(void)refreshIsRequire;<br />@end<br /><br /><br /><br /><br />@interface LoadingToolBar : UIToolbar {<br /> <br /> id <RefreshDelegate> delegate;<br /><br /><br /> UIActivityIndicatorView *indicator;<br /> UILabel *state;<br /> UIBarButtonItem *refresh;<br /><br /><br />}<br /><br /><br />@property (nonatomic, assign) id <RefreshDelegate> delegate;<br />@property (nonatomic, retain) UILabel *state;<br /><br /><br />-(id)initWithFrame:(CGRect)frame indicatorStyle:(UIActivityIndicatorViewStyle)style indicatorSize:(CGSize)size;<br /><br /><br />-(void)startWithMessage:(NSString *)s;<br />-(void)stopWithMessage:(NSString *)s;<br />-(void)clique;<br /><br /><br />@end<br />
LoadingToolBar.m
<br />#import "LoadingToolBar.h"<br /><br /><br /><br /><br />@implementation LoadingToolBar<br /><br /><br />@synthesize state;<br />@synthesize delegate;<br /><br /><br />-(id)initWithFrame:(CGRect)frame indicatorStyle:(UIActivityIndicatorViewStyle)style indicatorSize:(CGSize)size<br />{<br /> if ((self = [super initWithFrame:frame]))<br /> {<br /> indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:style];<br /> [indicator setFrame:CGRectMake(self.frame.size.width-size.width-5, (self.frame.size.height/2)-(size.height/2), size.width, size.height)];<br /> <br /> refresh = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(clique)];<br /> [refresh setStyle:UIBarButtonItemStylePlain];<br /> <br /> state = [[UILabel alloc] initWithFrame:CGRectMake(50, 0, 200, self.frame.size.height)];<br /> [state setBackgroundColor:[UIColor clearColor]];<br /> [state setFont:[UIFont systemFontOfSize:12]];<br /> [state setTextColor:[UIColor whiteColor]];<br /> <br /> [self setItems:[NSArray arrayWithObjects:refresh,nil]];<br /> [self addSubview:indicator];<br /> [self addSubview:state];<br /> }<br /> return self;<br />}<br /><br /><br />-(void)clique<br />{<br /> [delegate refreshIsRequire];<br />}<br /><br /><br />-(void)startWithMessage:(NSString *)s<br />{<br /> [indicator startAnimating];<br /> [state setText:s];<br />}<br /><br /><br />-(void)stopWithMessage:(NSString *)s<br />{<br /> [indicator stopAnimating];<br /> [state setText:s];<br />}<br /><br /><br />-(void)dealloc<br />{<br /> [indicator release];<br /> [state release];<br /> [refresh release];<br /> [super dealloc];<br />}<br /><br /><br />@end<br />
Pour l'utiliser c'est tout simple. Par exemple dans un UITableViewController :
.h
<br />#import "LoadingToolBar.h"<br /><br /><br />@interface RootViewController : UITableViewController <RefreshDelegate> {<br /> <br /> LoadingToolBar *toolBar;<br />}<br /><br /><br />@end<br />
.m
<br />- (void)viewDidLoad <br />{<br /> [super viewDidLoad];<br /><br /><br /> toolBar = [[LoadingToolBar alloc] initWithFrame:CGRectMake(0, self.navigationController.view.frame.size.height-44, 320, 44) indicatorStyle:UIActivityIndicatorViewStyleWhite indicatorSize:CGSizeMake(20, 20)];<br /> [toolBar setDelegate:self];<br /> <br /> [self.navigationController.view addSubview:toolBar];<br />}<br /><br />-(void)refreshIsRequire<br />{<br /> // Bouton refresh appuyé<br />}<br />
J'espère que ça vous servira !

Connectez-vous ou Inscrivez-vous pour répondre.
Réponses
MERCIIIIIIIIII !!!!!
De rien ^^
Y aurait moins de guerre si il y avait plus de choses comme ça