#import "ViewController.h"
#import <MapKit/MapKit.h>
@interface ViewController ()<MKMapViewDelegate,CLLocationManagerDelegate>
@property(nonatomic,strong)MKMapView *mapView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_mapView = [[MKMapView alloc] initWithFrame:self.view.frame];
// 设置地图显示n风格
[_mapView setMapType:MKMapTypeStandard];
// 设置缩放
[_mapView setZoomEnabled:YES];
// 设置滑动
[_mapView setScrollEnabled:YES];
// 设置旋转
[_mapView setRotateEnabled:YES];
// 显示m当前位置
[_mapView setShowsUserLocation:YES];
_mapView.delegate =self;
[self jingdu:40.045612 weidu:116.30612];
[self.view addSubview:_mapView];
}
-(void)jingdu:(CLLocationDegrees)j weidu:(CLLocationDegrees)w
{
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(j, w);
MKCoordinateSpan span =MKCoordinateSpanMake(0.1, 0.1);
MKCoordinateRegion regs= MKCoordinateRegionMake(center, span);
[self.mapView setRegion:regs animated:YES];
}
@end
UITableView *tbv;
UIScrollView *scro;
UIPageControl *pag;
NSTimer*timer;
intk;
// 初始化滚动式图
scro= [[UIScrollViewalloc]initWithFrame:CGRectMake(0,50,self.view.frame.size.width,200)];
// 设置滚动范围
scro.contentSize = CGSizeMake(3 * self.view.frame.size.width, 0);
// 禁用弹簧效果
scro.bounces=NO;
// 禁用水平滚动
scro.showsHorizontalScrollIndicator = NO;
// 设置整页滚动
scro.pagingEnabled = YES;
// 设置代理
scro.delegate=self;
// 设置滚动图片
for(inti =0; i <3; i++){
// 设置图片数组
NSArray*arr =@[@"1",@"2",@"3"];
UIImageView*imgV = [[UIImageViewalloc]initWithFrame:CGRectMake(i *self.view.frame.size.width,0,self.view.frame.size.width,200)];
// 加载图片
imgV.image= [UIImageimageNamed:arr[i]];
// 添加到滚动视图中
[scroaddSubview:imgV];
}
// 添加到cell中
[celladdSubview:scro];
// 设置豆豆
pag = [[UIPageControl alloc]initWithFrame:CGRectMake(90, 95, 150, 25)];
// 设置豆豆的数量
pag.numberOfPages = 3;
// 设置豆豆的颜色
pag.currentPageIndicatorTintColor = [UIColor orangeColor];
pag.pageIndicatorTintColor = [UIColor whiteColor];
// 添加到单元格中
[celladdSubview:pag];
// 创建定时器
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(aaa) userInfo:nil repeats:YES];
returncell;
}
// 滚动视图
- (void)scrollViewDidScroll:(UIScrollView*)scrollView{
// NSLog(@"%lf",scro.contentOffset.x);
pag.currentPage = scro.contentOffset.x/self.view.frame.size.width;
}
// 定时器
-(void)aaa{
[scro setContentOffset:CGPointMake(k * self.view.frame.size.width, 0)];
k++;
if(k>2){
k=0;
}
}
网友评论