Skip to content
This repository
Newer
Older
100644 175 lines (143 sloc) 7.32 kb
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
1 // MBProgressHUD.h
2 // Version 0.31
3 // Created by Matej Bukovinski on 30.9.09.
0a5c6191 »
2009-05-31 First commit
4
059cf871 »
2009-10-20 Importing 0.31 from zip download
5 // This code is distributed under the terms and conditions of the MIT license.
0a5c6191 »
2009-05-31 First commit
6
7 // Copyright (c) 2009 Matej Bukovinski
8 //
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
9 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
10 // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to the following conditions:
0a5c6191 »
2009-05-31 First commit
13 //
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
14 // The above copyright notice and this permission notice shall be included in all copies or substantial portions of
15 // the Software.
0a5c6191 »
2009-05-31 First commit
16 //
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
18 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
0a5c6191 »
2009-05-31 First commit
22
23 #import <UIKit/UIKit.h>
24
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
25 /** MBProgressHUD operation modes. */
26 typedef enum
27 {
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
28 /** Progress is shown using an UIActivityIndicatorView. This is the default. */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
29 MBProgressHUDModeIndeterminate,
30 /** Progress is shown using a MBRoundProgressView. */
059cf871 »
2009-10-20 Importing 0.31 from zip download
31 MBProgressHUDModeDeterminate,
32 } MBProgressHUDMode;
33
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
34 /** Defines callback methods for MBProgressHUD delegates. */
059cf871 »
2009-10-20 Importing 0.31 from zip download
35 @protocol MBProgressHUDDelegate
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
36 /** A callback function that is called after the HUD was fully hidden from the screen. */
059cf871 »
2009-10-20 Importing 0.31 from zip download
37 - (void)hudWasHidden;
38 @end
39
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
40 /** A progress view for showing definite progress by filling up a circle (similar to the indicator for building in
41 * xcode).
059cf871 »
2009-10-20 Importing 0.31 from zip download
42 */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
43 @interface MBRoundProgressView : UIProgressView
44 {
059cf871 »
2009-10-20 Importing 0.31 from zip download
45 }
46
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
47 /** Create a 37 by 37 pixel indicator. This is the same size as used by the larger UIActivityIndicatorView. */
059cf871 »
2009-10-20 Importing 0.31 from zip download
48 - (id)initWithDefaultSize;
49 @end
50
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
51 /** Displays a simple HUD window containing a UIActivityIndicatorView and two optional labels for short messages.
52 *
53 * This is a simple drop-in class for displaying a progress HUD view similar to Apples private UIProgressHUD class.
54 * The MBProgressHUD window spans over the entire space given to it by the initWithFrame constructor and catches all
55 * user input on this region, thereby preventing the user operations on components below the view. The HUD itself is
56 * drawn centered as a rounded semi-transparent view witch resizes depending on the user specified content.
0a5c6191 »
2009-05-31 First commit
57 *
58 * This view supports three modes of operation:
059cf871 »
2009-10-20 Importing 0.31 from zip download
59 * - The default mode displays just a UIActivityIndicatorView.
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
60 * - If the labelText property is set and non-empty then a label containing the provided content is placed below the
61 * UIActivityIndicatorView.
62 * - If also the detailsLabelText property is set then another label is placed below the first label.
0a5c6191 »
2009-05-31 First commit
63 */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
64 @interface MBProgressHUD : UIView
65 {
059cf871 »
2009-10-20 Importing 0.31 from zip download
66 MBProgressHUDMode mode;
67
0a5c6191 »
2009-05-31 First commit
68 SEL methodForExecution;
69 id targetForExecution;
70 id objectForExecution;
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
71 BOOL useAnimation;
72
73 float yOffset;
74 float xOffset;
059cf871 »
2009-10-20 Importing 0.31 from zip download
75
0a5c6191 »
2009-05-31 First commit
76 float width;
77 float height;
059cf871 »
2009-10-20 Importing 0.31 from zip download
78
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
79 NSUInteger delay;
80
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
81 UIView* indicator;
82 UILabel* label;
83 UILabel* detailsLabel;
059cf871 »
2009-10-20 Importing 0.31 from zip download
84
85 float progress;
86
87 id<MBProgressHUDDelegate> delegate;
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
88 NSString* labelText;
89 NSString* detailsLabelText;
0a5c6191 »
2009-05-31 First commit
90 float opacity;
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
91 UIFont* labelFont;
92 UIFont* detailsLabelFont;
ce752d9d »
2009-11-08 Added delayed display.
93
94 BOOL isFinished;
0a5c6191 »
2009-05-31 First commit
95 }
96
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
97 /** A convenience constructor that initializes the HUD with the window's bounds. Calls the designated constructor with
98 * window.bounds as the parameter.
0a5c6191 »
2009-05-31 First commit
99 */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
100 - (id)initWithWindow:(UIWindow*)window;
0a5c6191 »
2009-05-31 First commit
101
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
102 /** MBProgressHUD operation mode. Switches between indeterminate (MBProgressHUDModeIndeterminate) and determinate
103 * progress (MBProgressHUDModeDeterminate). The default is MBProgressHUDModeIndeterminate.
0a5c6191 »
2009-05-31 First commit
104 */
059cf871 »
2009-10-20 Importing 0.31 from zip download
105 @property (assign) MBProgressHUDMode mode;
0a5c6191 »
2009-05-31 First commit
106
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
107 /** The HUD delegate object. If set the delegate will receive hudWasHidden callbacks when the HUD was hidden. The
108 * delegate should conform to the MBProgressHUDDelegate protocol and implement the hudWasHidden method. The delegate
109 * object will not be retained.
059cf871 »
2009-10-20 Importing 0.31 from zip download
110 */
111 @property (assign) id<MBProgressHUDDelegate> delegate;
112
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
113 /** An optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit
114 * the entire text. If the text is too long it will get clipped by displaying "..." at the end. If left unchanged or
115 * set to @"", then no message is displayed.
0a5c6191 »
2009-05-31 First commit
116 */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
117 @property (copy) NSString* labelText;
0a5c6191 »
2009-05-31 First commit
118
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
119 /** An optional details message displayed below the labelText message. This message is displayed only if the labelText
120 * property is also set and is different from an empty string (@"").
0a5c6191 »
2009-05-31 First commit
121 */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
122 @property (copy) NSString* detailsLabelText;
0a5c6191 »
2009-05-31 First commit
123
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
124 /** The opacity of the HUD window. Defaults to 0.9 (90% opacity). */
0a5c6191 »
2009-05-31 First commit
125 @property (assign) float opacity;
126
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
127 /** The x-axis offset of the HUD relative to the centre of the window. */
128 @property (assign) float xOffset;
129
130 /** The y-ayis offset of the HUD relative to the centre of the window. */
131 @property (assign) float yOffset;
132
133 /** The number of milliseconds to displaying the HUD after start. */
134 @property (assign) NSUInteger delay;
135
136 /** Font to be used for the main label. Set this property if the default is not adequate. */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
137 @property (retain) UIFont* labelFont;
0a5c6191 »
2009-05-31 First commit
138
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
139 /** Font to be used for the details label. Set this property if the default is not adequate. */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
140 @property (retain) UIFont* detailsLabelFont;
0a5c6191 »
2009-05-31 First commit
141
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
142 /** The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0. */
059cf871 »
2009-10-20 Importing 0.31 from zip download
143 @property (assign) float progress;
0a5c6191 »
2009-05-31 First commit
144
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
145 /** Display the HUD. You need to make sure that the main thread completes its run loop soon after this method call so
146 * the user interface can be updated. Call this method when your task is already set-up to be executed in a new thread
147 * (e.g., when using something like NSOperation or calling an asynchronous call like NSUrlRequest).
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
148 *
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
149 * @param animated If set to YES the HUD will appear using a fade animation. If set to NO the HUD will not use
150 * animations while appearing.
201c6cd1 »
2009-05-31 Add hide/show functions.
151 */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
152 - (void)show:(BOOL)animated;
201c6cd1 »
2009-05-31 Add hide/show functions.
153
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
154 /** Hide the HUD, this still calls the hudWasHidden delegate. This is the counterpart of the hide: method. Use it to
155 * hide the HUD when your task completes.
156 *
157 * @param animated If set to YES the HUD will disappear using a fade animation. If set to NO the HUD will not use
158 * animations while disappearing.
201c6cd1 »
2009-05-31 Add hide/show functions.
159 */
4f5b96f6 »
2009-10-20 Reformatting the code to look like I like it.
160 - (void)hide:(BOOL)animated;
201c6cd1 »
2009-05-31 Add hide/show functions.
161
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
162 /** Shows the HUD while a background task is executing in a new thread, then hides the HUD.
059cf871 »
2009-10-20 Importing 0.31 from zip download
163 *
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
164 * This method also takes care of NSAutoreleasePools so your method does not have to be concerned with setting up a
165 * pool.
059cf871 »
2009-10-20 Importing 0.31 from zip download
166 *
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
167 * @param method The method to be executed while the HUD is shown. This method will be executed in a new thread.
059cf871 »
2009-10-20 Importing 0.31 from zip download
168 * @param target The object that the target method belongs to.
169 * @param object An optional object to be passed to the method.
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
170 * @param animated If set to YES the HUD will appear and disappear using a fade animation. If set to NO the HUD will
171 * not use animations while appearing and disappearing.
0a5c6191 »
2009-05-31 First commit
172 */
fee25a50 »
2009-11-08 Adding offsets and delays. Offsets work, but don't protect against ov…
173 - (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated;
0a5c6191 »
2009-05-31 First commit
174 @end
Something went wrong with that request. Please try again.