Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 45226fe0
由
cgx
编写于
2022-06-16 14:50:07 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
完善我的添加图片网络异常处理
1 个父辈
ec2ed233
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
68 行增加
和
31 行删除
DreamSleep/DreamSleep/Basement/H5/ExceptionDefaultView.h
DreamSleep/DreamSleep/Basement/H5/ExceptionDefaultView.m
DreamSleep/DreamSleep/Class/ProfileModule/Me/ProfileTableView.m
DreamSleep/DreamSleep/Basement/H5/ExceptionDefaultView.h
查看文件 @
45226fe
...
@@ -11,7 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -11,7 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
// 异常处理类型
// 异常处理类型
typedef
NS_ENUM
(
NSInteger
,
ExceptionType
)
{
typedef
NS_ENUM
(
NSInteger
,
ExceptionType
)
{
ExceptionTypeNet
ExceptionTypeNet
,
ExceptionTypeSmall
};
};
// 处理事件回调
// 处理事件回调
...
...
DreamSleep/DreamSleep/Basement/H5/ExceptionDefaultView.m
查看文件 @
45226fe
...
@@ -25,30 +25,48 @@
...
@@ -25,30 +25,48 @@
self
.
hidden
=
YES
;
self
.
hidden
=
YES
;
[
superView
addSubview
:
self
];
[
superView
addSubview
:
self
];
[
self
addSubview
:
self
.
exceptionIV
];
[
self
addSubview
:
self
.
exceptLab
];
[
self
addSubview
:
self
.
exceptLab
];
[
self
addSubview
:
self
.
dealBtn
];
[
self
addSubview
:
self
.
dealBtn
];
[
self
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
if
(
type
==
ExceptionTypeNet
)
{
make
.
left
.
right
.
equalTo
(
superView
);
[
self
addSubview
:
self
.
exceptionIV
];
make
.
center
.
equalTo
(
superView
);
}];
[
self
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
[
self
.
exceptionIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
right
.
equalTo
(
superView
);
make
.
centerX
.
equalTo
(
self
);
make
.
center
.
equalTo
(
superView
);
make
.
top
.
equalTo
(
self
);
}];
}];
[
self
.
exceptionIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
[
self
.
exceptLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
centerX
.
equalTo
(
self
);
make
.
top
.
equalTo
(
self
);
make
.
left
.
equalTo
(
self
).
offset
(
5
);
}];
make
.
right
.
equalTo
(
self
).
offset
(
-
5
);
[
self
.
exceptLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
self
.
exceptionIV
.
mas_bottom
).
offset
(
42
);
make
.
centerX
.
equalTo
(
self
);
}];
make
.
left
.
equalTo
(
self
).
offset
(
5
);
[
self
.
dealBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
right
.
equalTo
(
self
).
offset
(
-
5
);
make
.
centerX
.
equalTo
(
self
);
make
.
top
.
equalTo
(
self
.
exceptionIV
.
mas_bottom
).
offset
(
42
);
make
.
size
.
mas_equalTo
(
CGSizeMake
(
155
,
40
));
}];
make
.
top
.
equalTo
(
self
.
exceptLab
.
mas_bottom
).
offset
(
42
);
[
self
.
dealBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
bottom
.
equalTo
(
self
).
offset
(
-
30
);
make
.
centerX
.
equalTo
(
self
);
}];
make
.
size
.
mas_equalTo
(
CGSizeMake
(
155
,
40
));
make
.
top
.
equalTo
(
self
.
exceptLab
.
mas_bottom
).
offset
(
42
);
make
.
bottom
.
equalTo
(
self
).
offset
(
-
30
);
}];
}
else
if
(
type
==
ExceptionTypeSmall
)
{
[
self
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
left
.
bottom
.
right
.
equalTo
(
superView
);
}];
[
self
.
exceptLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
left
.
equalTo
(
self
).
offset
(
5
);
make
.
right
.
equalTo
(
self
).
offset
(
-
5
);
make
.
centerY
.
equalTo
(
self
).
offset
(
-
30
);
}];
[
self
.
dealBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
size
.
mas_equalTo
(
CGSizeMake
(
155
,
40
));
make
.
centerY
.
equalTo
(
self
).
offset
(
30
);
}];
}
}
}
return
self
;
return
self
;
}
}
...
@@ -89,6 +107,8 @@
...
@@ -89,6 +107,8 @@
NSString
*
info
=
@""
;
NSString
*
info
=
@""
;
if
(
type
==
ExceptionTypeNet
)
{
if
(
type
==
ExceptionTypeNet
)
{
info
=
@"当前网络环境较差,点击刷新重新加载~"
;
info
=
@"当前网络环境较差,点击刷新重新加载~"
;
}
else
if
(
type
==
ExceptionTypeSmall
)
{
info
=
@"当前网络环境较差,点击刷新重新加载~"
;
}
}
return
info
;
return
info
;
}
}
...
@@ -97,6 +117,8 @@
...
@@ -97,6 +117,8 @@
NSString
*
title
=
@""
;
NSString
*
title
=
@""
;
if
(
type
==
ExceptionTypeNet
)
{
if
(
type
==
ExceptionTypeNet
)
{
title
=
@"刷新"
;
title
=
@"刷新"
;
}
else
if
(
type
==
ExceptionTypeSmall
)
{
title
=
@"刷新"
;
}
}
return
title
;
return
title
;
}
}
...
...
DreamSleep/DreamSleep/Class/ProfileModule/Me/ProfileTableView.m
查看文件 @
45226fe
...
@@ -128,6 +128,7 @@
...
@@ -128,6 +128,7 @@
@property
(
nonatomic
,
strong
)
UIView
*
footerView
;
@property
(
nonatomic
,
strong
)
UIView
*
footerView
;
@property
(
nonatomic
,
strong
)
UIImageView
*
introduceIV
;
@property
(
nonatomic
,
strong
)
UIImageView
*
introduceIV
;
@property
(
nonatomic
,
strong
)
NSURL
*
introduceUrl
;
@property
(
nonatomic
,
strong
)
NSURL
*
introduceUrl
;
@property
(
nonatomic
,
strong
)
ExceptionDefaultView
*
exceptionView
;
@end
@end
@implementation
ProfileTableView
@implementation
ProfileTableView
...
@@ -145,14 +146,7 @@
...
@@ -145,14 +146,7 @@
self
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
self
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
[
self
registerClass
:[
ProfileCell
class
]
forCellReuseIdentifier
:
NSStringFromClass
([
ProfileCell
class
])];
[
self
registerClass
:[
ProfileCell
class
]
forCellReuseIdentifier
:
NSStringFromClass
([
ProfileCell
class
])];
WS
(
weakSelf
);
self
.
introduceUrl
=
[
NSURL
URLWithString
:
@"https://img2.ydniu.com/sleep_ssmain/cbti_cover.png"
];
self
.
mj_header
=
[
DSGifHeader
headerWithRefreshingBlock
:
^
{
[
weakSelf
.
introduceIV
yy_setImageWithURL
:
self
.
introduceUrl
placeholder
:[
UIImage
imageNamed
:
@"bannerPlaceholder"
]
options
:
YYWebImageOptionShowNetworkActivity
completion
:^
(
UIImage
*
_Nullable
image
,
NSURL
*
_Nonnull
url
,
YYWebImageFromType
from
,
YYWebImageStage
stage
,
NSError
*
_Nullable
error
)
{
[
weakSelf
.
mj_header
endRefreshing
];
if
(
error
)
{
[
DSProgressHUD
showToast
:
@"网络异常,请稍候重试"
];
}
}];
}];
}
}
return
self
;
return
self
;
}
}
...
@@ -262,13 +256,33 @@
...
@@ -262,13 +256,33 @@
UIImageView
*
introduceIV
=
[[
UIImageView
alloc
]
initWithFrame
:
CGRectMake
(
15
,
15
,
width
,
height
)];
UIImageView
*
introduceIV
=
[[
UIImageView
alloc
]
initWithFrame
:
CGRectMake
(
15
,
15
,
width
,
height
)];
[
introduceIV
cornerRadius
:
12
.
0
];
[
introduceIV
cornerRadius
:
12
.
0
];
introduceIV
.
userInteractionEnabled
=
YES
;
introduceIV
.
userInteractionEnabled
=
YES
;
[
introduceIV
yy_setImageWithURL
:
self
.
introduceUrl
placeholder
:[
UIImage
imageNamed
:
@"bannerPlaceholder"
]];
[
_footerView
addSubview
:
introduceIV
];
[
_footerView
addSubview
:
introduceIV
];
UITapGestureRecognizer
*
tapGR
=
[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
tapCBTIAction
)];
UITapGestureRecognizer
*
tapGR
=
[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
tapCBTIAction
)];
[
introduceIV
addGestureRecognizer
:
tapGR
];
[
introduceIV
addGestureRecognizer
:
tapGR
];
self
.
introduceIV
=
introduceIV
;
self
.
introduceIV
=
introduceIV
;
[
self
loadImg
];
}
}
return
_footerView
;
return
_footerView
;
}
}
-
(
ExceptionDefaultView
*
)
exceptionView
{
if
(
!
_exceptionView
)
{
WS
(
weakSelf
);
_exceptionView
=
[[
ExceptionDefaultView
alloc
]
initWithType
:
ExceptionTypeSmall
block
:
^
{
weakSelf
.
exceptionView
.
hidden
=
YES
;
[
weakSelf
loadImg
];
}
superView
:
self
.
footerView
];
}
return
_exceptionView
;
}
-
(
void
)
loadImg
{
WS
(
weakSelf
);
[
self
.
introduceIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
@"https://img2.ydniu.com/sleep_ssmain/cbti_cover.png"
]
placeholder
:[
UIImage
imageNamed
:
@"bannerPlaceholder"
]
options
:
YYWebImageOptionShowNetworkActivity
completion
:^
(
UIImage
*
_Nullable
image
,
NSURL
*
_Nonnull
url
,
YYWebImageFromType
from
,
YYWebImageStage
stage
,
NSError
*
_Nullable
error
)
{
weakSelf
.
exceptionView
.
hidden
=
error
?
NO
:
YES
;
weakSelf
.
introduceIV
.
hidden
=
!
weakSelf
.
exceptionView
.
hidden
;
}];
}
@end
@end
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论