本文解答了关于《自身基础的定位》相关内容,同时关于1、自身基础的定位是什么,2、自身定位的重要性,3、基本定位,4、自身定位怎么写,5、确定自身定位,的相关问答本篇文章福途教育网小编也整理了进来,希望对您有帮助。
自身基础的定位
_swipe=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
_swipe.direction=UISwipeGestureRecognizerDirectionRight;
[self addGestureRecognizer:_swipe];
}
- (void)swipeGesture:(UISwipeGestureRecognizer *)swipe{
NSInteger nowPostion=_scrollView.contentOffset.x/_scrollView.frame.size.width;
NSInteger numberOfPage=self.imageViewArray.count;
if (swipe.direction == UISwipeGestureRecognizerDirectionRight) {
if (nowPostion==0) {
[_scrollView setContentOffset:CGPointMake(_scrollView.frame.size.width*(numberOfPage-2), 0) animated:YES];
_pathnum=(numberOfPage-2);
}else{
[_scrollView setContentOffset:CGPointMake(_scrollView.frame.size.width*(nowPostion-1), 0) animated:YES];
_pathnum=nowPostion-1;
}
}
}
- (void)didMoveToWindow{
[self user_delay];
}
- (void)user_delay{
//仅仅执行一次
[UIView animateWithDuration:0.6 animations:^{
_scrollView.contentOffset = CGPointMake([UIScreen mainScreen].bounds.size.width, 0);
}];
}
- (void)reloadData{
_pageC=[[UIPageControl alloc] initWithFrame:CGRectMake(0, self.frame.size.height-25, self.frame.size.width, 25)];
_pageC.numberOfPages=self.imageViewArray.count-2;
_pageC.userInteractionEnabled=NO;
_pageC.currentPage=0;
[self addSubview:_pageC];
[self bringSubviewToFront:_pageC];
for (NSInteger i=0; i UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(i*[UIScreen mainScreen].bounds.size.width, 0, [UIScreen mainScreen].bounds.size.width, _frame.size.height)];
[imageView sd_setImageWithURL:[NSURL URLWithString:self.imageViewArray[i]] placeholderImage:nil];
[_scrollView addSubview:imageView];
}
[UIView animateWithDuration:_timeInteval animations:^{
_scrollView.contentOffset = CGPointMake([UIScreen mainScreen].bounds.size.width, 0);
}];
if (_bannerArray.count) {
_bannerView.text=_bannerArray[0];
}
}
- (void)pageCSelect:(UIPageControl *)pagec{
[_scrollView setContentOffset:CGPointMake(_frame.size.width*_pageC.currentPage, 0) animated:YES];
_pathnum=_pageC.currentPage;
}
#pragma mark ScrollviewDelegate
//滚动视图结束减速时
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
NSInteger pageInt=scrollView.contentOffset.x/scrollView.frame.size.width;
if(pageInt==0){
pageInt=_imageViewArray.count-2;
}
else if (pageInt==_imageViewArray.count-1) {
pageInt=1;
}
[_scrollView setContentOffset:CGPointMake(_scrollView.frame.size.width*(pageInt-1), 0) animated:NO];
_pageC.currentPage=pageInt-1;
_pathnum=pageInt-1;
if (_bannerArray.count) {
_bannerView.text=_bannerArray[pageInt-1];
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
// NSInteger pageInt=_scrollView.contentOffset.x/_scrollView.frame.size.width;
// if(pageInt==0){
// pageInt=_imageViewArray.count-2;
// }else{
// pageInt=pageInt-1;
// }
if (scrollView==self.scrollView) {
_pageC.currentPage=scrollView.contentOffset.x/(CGFloat)scrollView.frame.size.width-1;
}
}
@end
总结:以上是编辑:【孙浛】整理及AI智能原创关于《自身基础的定位
》优质内容解答希望能帮助到您。