关于UIScollectionView使用,字体打印,判断定位是否开启
来源:互联网 发布:python 写服务 编辑:程序博客网 时间:2024/05/17 08:20
@property (assign,nonatomic)int page;
@property (assign,nonatomic)int pageCount;
@property (strong,nonatomic) ScrollView *scrollView;
@end
@implementation MainViewController
// 构建广告滚动视图
- (void)createScrollView {
self.scrollView = [[AdvertisingScrollViewalloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH,175)];
self.scrollView.contentInset =UIEdgeInsetsMake(0,0, 0, 0);
self.scrollView.imageNameArray = [NSArrayarrayWithObjects:@"picture1.png",@"picture2.png",@"picture3.png",@"picture4.png",nil];
self.scrollView.PageControlShowStyle =UIPageControlShowStyleCenter;
self.scrollView.pageControl.pageIndicatorTintColor = [UIColor whiteColor];
self.scrollView.pageControl.currentPageIndicatorTintColor = [UIColor grayColor];
[self.viewaddSubview:self.scrollView];
}
- (id)init
{
self = [superinit];
if (self) {
//[self setup];
}
return self;
}
//加载新数据
-(void)LoadNewMessage
{
}
//向上重新加载数据
-(void)UpReloadData
{//当页面小于总页数就加入数据 否则等于原始数据
[self.collectionViewaddHeaderWithCallback:^{
if (self.page <self.pageCount) {
self.page ++;
}else {
self.page =self.pageCount;
}
[selfLoadNewMessage];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
// 结束刷新
[self.collectionViewheaderEndRefreshing];
});
}];
}
//向下重新加载数据
-(void)DownReloadData
{
[self.collectionViewaddFooterWithCallback:^{
if (self.page <self.pageCount) {
self.page ++;
}else {
self.page =self.pageCount;
}
[selfLoadNewMessage];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
// 结束刷新
[self.collectionViewfooterEndRefreshing];
});
}];
}
- (void)dealloc
{
NSLog(@"MJCollectionViewController--dealloc---");
}
- (void)viewDidLoad {
/* x = 0; // 打印所有字体名
y= 0;
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames ){
x++;
NSLog( @"===%d=Family: %s \n",x, [familyName UTF8String] );
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
for( NSString *fontName in fontNames ){
y++;
// printf( "-%d---\tFont: [[%s]] \n]", y,[fontName UTF8String] );
}
}*/
// MicrosoftYaHei
[superviewDidLoad];
self.page =0;
self.pageCount =0;
[selfcreateScrollView];
selectedIdx = [NSMutableDictionarynew];
//判断定位是否开启
if ([CLLocationManagerlocationServicesEnabled] &&
([CLLocationManagerauthorizationStatus] == kCLAuthorizationStatusAuthorized
|| [CLLocationManagerauthorizationStatus] == kCLAuthorizationStatusNotDetermined)) {
NSLog(@"定位功能以及开启");
}
elseif ([CLLocationManagerauthorizationStatus] == kCLAuthorizationStatusDenied){
NSLog(@"定位功能不可用,提示用户或忽略");
}
NavigationView *navigationView = [NavigationViewnew];
[self.viewaddSubview:navigationView];
int navigationHeight = navigationView.frame.size.height;
self.navigationController.navigationBarHidden=YES;//隐藏导航栏
//[UIColor colorWithRed:0/152.0f green:122/148.0f blue:255/142.0f alpha:0.5];
//self.view.backgroundColor = [UIColor whiteColor];
//首页滚动推荐图
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayoutalloc] init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
self.collectionView = [[UICollectionViewalloc]initWithFrame:CGRectMake(0, navigationHeight,self.view.frame.size.width,self.view.frame.size.height - navigationHeight -49) collectionViewLayout:flowLayout];
flowLayout.headerReferenceSize =CGSizeMake(self.view.frame.size.width,175);
flowLayout.minimumInteritemSpacing =0;
//间距
flowLayout.minimumLineSpacing =4;
flowLayout.sectionInset =UIEdgeInsetsMake(4,4, 0, 4);
self.automaticallyAdjustsScrollViewInsets =NO;//顶部不预留空白区域
self.collectionView.delegate =self;
self.collectionView.dataSource =self;
[self.collectionViewregisterClass:[ProjectCollectionViewCellclass] forCellWithReuseIdentifier:CellIdentifier];
[self.collectionViewsetAllowsMultipleSelection:YES];
[self.viewaddSubview:self.collectionView];
[self.collectionViewaddSubview:self.scrollView];
EntityInformation *entity = [EntityInformationnew];
aryInformation = [entityinfomationCategoryArray];
[self.collectionViewreloadData];
// 2.集成刷新控件
[selfUpReloadData];
[selfDownReloadData];
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
returnaryInformation.count;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
int cellWidth;
int cellHight = (self.view.frame.size.width -16)/3;
switch (indexPath.row %3) {
case 0: case 1:
cellWidth = (self.view.frame.size.width - 16)/3;
break;
case 2:
cellWidth = (self.view.frame.size.width - 16)/3 + 1;
break;
default:
break;
}
return CGSizeMake(cellWidth,cellHight);
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
ProjectCollectionViewCell *cell=(ProjectCollectionViewCell *)[collectionViewdequeueReusableCellWithReuseIdentifier:CellIdentifierforIndexPath:indexPath];//@"cellEmpty"
cell.row = indexPath.row %3;
[cellsetInformationCell:aryInformation[indexPath.row]];
return cell;
}
//选中
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[selectedIdxsetValue:@"1"forKey:[NSStringstringWithFormat:@"%ld",(long)indexPath.row]];
NSUserDefaults *defaults = [NSUserDefaultsstandardUserDefaults];
BOOL switchOn =[defaults boolForKey:@"switchOn"];
if (!switchOn) {
InformationClassificationViewController *icvc=[InformationClassificationViewControllernew];
[selfpresentViewController:icvc animated:YEScompletion:nil];
}else {
SecondViewController *svc = [SecondViewControllernew];
[selfpresentViewController:svc animated:YEScompletion:nil];
}
}
//取消选择
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
[selectedIdxremoveObjectForKey:[NSStringstringWithFormat:@"%ld", (long)indexPath.row]];
}
-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
}
- (void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath {
}
- 关于UIScollectionView使用,字体打印,判断定位是否开启
- 判断是否开启定位
- 如何判断应用是否允许开启定位
- 判断用户是否开启了定位功能
- 判断是否开启定位服务的方法
- IOS 判断定位服务是否开启代码
- ios判断是否开启了定位
- Android之如何判断定位是否开启及定位模式
- Android定位入门(2)判断GPS是否开启
- iOS开发 判断用户是否开启了定位服务
- ios 判断用户是否开启定位权限并跳转设置
- 判断APP用户手机是否开启了定位服务
- 判断定位服务是否开启(手机上位置信息按钮开关)
- 判断APP用户手机是否开启了定位服务
- 定位权限是否开启
- 判断cookie是否开启
- 判断gps是否开启
- 判断gps是否开启
- jdbcTemplate的取值方法和注意事件
- 【iOS开发-120】在storyboard中如何使用Size Classes,其实就是设置多套AutoLayout
- iOS强制屏幕旋转
- HDU 2438 Turn the corner(三分枚举角度)
- android之GPS
- 关于UIScollectionView使用,字体打印,判断定位是否开启
- 闭包
- UVA Shoemaker's Problem
- phonegap 弹出框的样式出现差异的问题
- rsync远程同步备份数据(ssh方式)
- Content-type的说明即HTTP请求头的类型整理
- java &和&&的区别
- java两个时间比较
- objective-c 学习2 概述