AI智能解答
_m_nCycle = [configDict[@"scrollCycle"] integerValue];
_m_nContentCount = 0;
_m_fCicleTime = 1.0;
_m_nCurrentShowCount = 0;
_m_nCurrentIndex = 0;
_m_arrScrollTasks = [NSMutableArray arrayWithCapacity:0];
_m_arrVisibleCells = [NSMutableArray arrayWithCapacity:0];
}
- (void)dealloc
{
[self StopScrollByUser];
[self RemoveAllCell];
[_m_arrScrollTasks removeAllObjects];
[_m_arrVisibleCells removeAllObjects];
}
- (UIView *)cellView
{
if (_dataSource && [self.dataSource respondsToSelector:@selector(keywordScrollView:cellForRowAtIndex:)])
{
_mCellView = [self.dataSource keywordScrollView:self cellForRowAtIndex:_m_nCurrentIndex];
}
return _mCellView;
}
#pragma mark
#pragma mark <——— 数据更新 - 增删 ———>
- (void)refreshCurrentIndex
{
__block NSInteger nNowIndex = _m_nCurrentIndex;
[_m_arrVisibleCells enumerateObjectsUsingBlock:^(UIView *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) {
if (obj.tag == (nNowIndex + kBaseContentTag))
{
_m_nCurrentIndex = nNowIndex;
*stop = YES;
}
nNowIndex ++;
}];
if (self.keyworddelegate && [self.keyworddelegate respondsToSelector:@selector(updateScrollIndex:)])
{
[self.keyworddelegate updateScrollIndex:_m_nCurrentIndex];
}
}
- (void)addCellAtLast
{
_m_nContentCount++;
[self addCell];
}
- (void)addCellAtFirst
{
_m_nContentCount++;
_m_nCurrentIndex = (_m_nContentCount - _m_nCurrentShowCount - 1);
[ self addCell];
}
- (void)addCellAtIndex:(NSInteger)index
{
_m_nContentCount++;
_m_nCurrentIndex = index;
[self addCell];
}
- (void)addCell
{
UIView *pCellview = [self cellView];
pCellview.tag = _m_nCurrentIndex + kBaseContentTag;
if (pCellview != nil)
{
CGPoint center = CGPointMake(self.center.x, self.center.y + (pCellview.frame.size.height / kDivideNumber));
pCellview.center = center;
[self.m_arrVisibleCells addObject:pCellview];
[self addSubview:pCellview];
}
if ( ( _m_nContentCount > _m_nCurrentShowCount) && _m_nContentCount == ( _m_nCurrentIndex + 1 ) )
{
[self refreshCurrentIndex];
}
}
- (void)RemoveFirstCell
{
_m_nContentCount--;
UIView *pCellview = [self.m_arrVisibleCells firstObject];
[pCellview removeFromSuperview];
[self.m_arrVisibleCells removeObjectAtIndex:0];
if (_m_nContentCount > 0)
{
[self moveViews];
[ self removeCellAtIndex:0];
}
if ( ( _m_nContentCount > _m_nCurrentShowCount) && _m_nContentCount == ( _m_nCurrentIndex + 1 ) )
{
[self refreshCurrentIndex];
}
}
- (void)removeCellAtLast
{
[self moveViews];
[self removeCellAtIndex:[self.m_arrVisibleCells count] - 1];
_m_nContentCount--;
}
- (void)removeCellAtIndex:(NSInteger )index
{
UIView *pCellview = [self.m_arrVisibleCells objectAtIndex:index];
[pCellview removeFromSuperview];
[self.m_arrVisibleCells removeObjectAtIndex:index];
}
- (void)RemoveAllCell
{
for (NSInteger nIndex = 0; nIndex < [_m_arrVisibleCells count]; nIndex++)
{
UIView *pCellview = [self.m_arrVisibleCells objectAtIndex:nIndex];
[self removeCellAtIndex:nIndex];
[pCellview removeFromSuperview];
}
}
#pragma mark
#pragma mark <——— 数据更新 - 刷新 ———>
- (void)updateForContentCount:(NSInteger)contentCnt
{
[self onStopScrollTimer];
if ([ _m_arrVisibleCells count] > 0)
{
[self RemoveAllCell];
}
if ((contentCnt == 0))// && (nRowNum == 0))
{
return;
}
if (contentCnt == 1)
{
UIView *pCellview = [self cellView];
pCellview.tag = 0 + kBaseContentTag;
CGPoint center = CGPointMake(self.center.x, self.center.y + (pCellview.frame.size.height / kDivideNumber));
pCellview.center = center;
[self addSubview:pCellview];
[_m_arrVisibleCells addObject: pCellview];
_m_nContentCount = 1;
_m_nCurrentIndex = -1;
_m_nCurrentShowCount = 1;
}
else
{
_m_nContentCount = contentCnt; //(nRowNum * _m_nRow)
_m_nCurrentIndex = 0;
[self addCellAtIndex:(_m_nContentCount - contentCnt)];
_m_nCurrentShowCount = [_m_arrVisibleCells count];
[self moveViews];
[self startScrollTimer];
}
}
#pragma mark
#pragma mark <——— 动画显示操作 ———>
- (void)animateScroll
{
[UIView animateWithDuration:_m_fCicleTime
animations:^()
{
CGFloat fRate = 16.0f; //16帧 等于 1秒
_m_nCurrentIndex = _m_nCurrentIndex + (1 / fRate); //下
[self MoveCurrentViewDown];
}
completion:^(BOOL finished)
{
[self MovePaddingViewUp];
}];
}
- (void)pauseScrollForTime
{
if (_m_nCycle > 0)
{
[self performSelector:@selector(startScrollTimer) withObject:nil afterDelay:_m_nCycle];
}
}
- (void)MovePaddingViewUp
{
//如果有内容
if (_m_nContentCount > 0)
{
int nStartIndex = _m_nCurrentIndex - _m_nCurrentShowCount;
if (nStartIndex < 0)
{
nStartIndex = _m_nContentCount + nStartIndex; //求余
_m_nCurrentIndex = nStartIndex;
for (NSInteger nIndex = 0; nIndex < _m_nCurrentShowCount; nIndex++)
{
_m_nCurrentIndex ++;
UIView *pCellview = [self cellView];
[self addCellAtIndex:_m_nCurrentIndex];
pCellview.tag = _m_nCurrentIndex + kBaseContentTag;
[_m_arrVisibleCells replaceObjectAtIndex:nIndex withObject:pCellview];
}
}
[self moveViews]; //调整坐标
[self refreshCurrentIndex];
[self animateScroll];
}
else
{
[self refreshCurrentIndex];
[self pauseScrollForTime];
}
}
- (void)MoveCurrentViewDown
{
CGFloat fContentHeight = 0.0;
for (NSInteger nIndex = 0; nIndex < [ _m_arrVisibleCells count]; nIndex++)
{
UIView *pCellview = [ _m_arrVisibleCells objectAtIndex:nIndex];
fContentHeight = (fContentHeight + pCellview.frame.size.height);
}
for (NSInteger nIndex = 0; nIndex < [ _m_arrVisibleCells count]; nIndex++)
{
UIView *pCellview = [_m_arrVisibleCells objectAtIndex:nIndex];
CGPoint center = CGPointMake(self.center.x,self.center.y + fContentHeight + (pCellview.frame.size.height / kDivideNumber));
[UIView animateWithDuration:0001
animations:^()
{
pCellview.center = center;
}];
fContentHeight = (fContentHeight - pCellview.frame.size.height) ;
}
}
#pragma mark
#pragma mark <——— 坐标调整 ———>
- (void)moveViews
{
CGFloat fContentHeight = 0;
for (NSInteger nIndex = 0; nIndex < [ _m_arrVisibleCells count]; nIndex++)
{
UIView *pCellview = [_m_arrVisibleCells objectAtIndex:nIndex];
fContentHeight = (fContentHeight + pCellview.frame.size.height);
}
fContentHeight = 0.0;
for (NSInteger nIndex = 0; nIndex < [ _m_arrVisibleCells count]; nIndex++)
{
UIView *pCellview = [ _m_arrVisibleCells objectAtIndex:nIndex];
CGPoint center = CGPointMake(self.center.x, self.center.y + fContentHeight + (pCellview.frame.size.height / kDivideNumber));
pCellview.center = center;
fContentHeight = (fContentHeight + pCellview.frame.size.height);
}
}
- (void)addTask:(NSInvocation *)pTask
{
NSString * strTaskID = [self CreateTaskID];
[_m_arrScrollTasks addObject:pTask]; //加入
[_m_arrScrollTasks addObject:strTaskID];
}
#pragma mark
#pragma mark <——— 定时器控制 ———>
- (void)onStopScrollTimer
{
if (_m_TimerScroll)
{
if ([_m_TimerScroll isValid])
{
[_m_TimerScroll invalidate];
}
_m_TimerScroll = nil;
}
}
- (void)startScrollTimer
{
if (!_m_TimerScroll)
{
_m_TimerScroll = [NSTimer scheduledTimerWithTimeInterval:0.0625f
target:self
selector:@selector(animateScroll)
userInfo:nil
repeats:YES];
}
}
- (void)StopScrollByUser
{
[self onStopScrollTimer];
}
- (void)ResumeForMinInterval
{
[self onStopScrollTimer];
if (_m_nContentCount > 1)
{
[self startScrollTimer];
}
}
- (NSString *)CreateTaskID
{
NSDate *date = [NSDate date];
NSTimeInterval fTime = [date timeIntervalSince1970];
NSString *strTaskID = [NSString stringWithFormat:@"%d",(int)fTime]; //时间戳
return strTaskID;
}
#pragma mark
#pragma mark <——— 点击事件 ———>
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UIView *view = [touches anyObject].view;
NSInteger nContentIndex = (view.tag - kBaseContentTag);
if ([_m_arrScrollTasks count] >= 2)
{
NSInvocation *pTask = [_m_arrScrollTasks firstObject];
NSString *strTaskID = [_m_arrScrollTasks lastObject];
[self StopScrollByUser]; //点击停止滚动
[pTask setArgument:(void *)&nContentIndex atIndex:2];
[pTask setArgument:(void *)strTaskID.UTF8String atIndex:3];
[pTask retainArguments];
[pTask invoke];
[_m_arrScrollTasks removeAllObjects];
}
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
2019年只通过《消防安全技术实务》,2020年通过《消防安全技术综合能力》,2021年未通过《消防安全案例分析》的,保留2022年《消防安全技术综合能力》的2020年考试成绩,2019年成绩作废。
参加一级注册消防工程师考试,免考科目《消防安全技术实务》的人员,需要连续两个考试年度参加科目《消防安全案例分析》和《消防安全技术实务》两个科目的考试并通过考试,方可取得一级注册消防工程师资格证书。