Closed aaa-1902 closed 1 year ago
This problem can be solved using a special protocol that allows you to set progress.
Firstly, create the protocol MBProgressHUDProgressRepresentable
in MBProgressHUD.h
@protocol MBProgressHUDProgressRepresentable <NSObject>
- (void)setProgress:(float)progress;
@end
Then, extend the MBRoundProgressView
to conforms MBProgressHUDProgressRepresentable
/**
* A progress view for showing definite progress by filling up a circle (pie chart).
*/
@interface MBRoundProgressView : UIView <MBProgressHUDProgressRepresentable>
Note: MBRoundProgressView
already has implementation for setProgress:
method
At the next step you need to forward MBProgressHUDProgressRepresentable
just like MBProgressHUDDelegate
@protocol MBProgressHUDDelegate;
@protocol MBProgressHUDProgressRepresentable; // <-- line to be added under @protocol MBProgressHUDDelegate;
And finaly replace this
if ([indicator respondsToSelector:@selector(setProgress:)]) {
[(id)indicator setProgress:progress];
}
by this:
if ([indicator conformsToProtocol:@protocol(MBProgressHUDProgressRepresentable)]) {
[(id<MBProgressHUDProgressRepresentable>)indicator setProgress: progress];
}
Note: if you are using customView
as indicator you need to conform customView
class to MBProgressHUDProgressRepresentable
There is an issue with this [(id)indicator setProgress:progress]
and shows a
"Multiple methods named 'setProgress:' found with mismatched result, parameter type or attributes"
errorThis was from a manually imported library and not through pods so I'm not quite sure how outdated this is.