永发信息网

ios 怎样添加一个加载loding

答案:1  悬赏:10  手机版
解决时间 2021-11-13 15:45
  • 提问者网友:抽煙菂渘情少年
  • 2021-11-13 00:00
ios 怎样添加一个加载loding
最佳答案
  • 五星知识达人网友:底特律间谍
  • 2021-11-13 00:52
项目中用到的加载框,每次单独写挺麻烦,现封装以一个类,方便使用(1)首先,在.h中进行一下操作

(2)其次,在.m中实现下面的操作
#import "LoadingViewController.h"
#import 
@interface hitView : UIView

@end
@implementation hitView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *hitView = [super hitTest:point withEvent:event];
if (hitView == self) return nil;
else return hitView;
}
@end







(3)为了方便起见,我使用xib协助写的,在xib 中实现下图的效果

封装完成后,在其他类中只需要实现
self.activityIndicatorView = [[[LoadingViewController alloc]init]autorelease];
[activityIndicatorView showLoadingWithTitle:@"正在加载请稍候..." inView:self.viewmode:DISMODELODING];就行了。
注:还可以在这个的基础上更进一步的封装;
在global_macro.h中将其声明成宏:#define LOADINGSHOW_MESSAGE(m,modes) [((AppDelegate *)[[UIApplication sharedApplication] delegate]).loadingViewController showLoadingWithTitle:m inView:[UIApplication sharedApplication].keyWindow mode:modes];
#define LOADINGDISMISS [((AppDelegate *)[[UIApplication sharedApplication] delegate]).loadingViewController dismissLoading];

#define GET_UDID [SSKeychain passwordForService:@"udid" account:@"currentUser"]

#define GET_APPID [[NSUserDefaults standardUserDefaults] stringForKey:@"appid"]
这样的话再用到的地方只需要引用定义好的宏即可。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯