当前位置: 首页 > wzjs >正文

centos建设网站江门网站开发多少钱

centos建设网站,江门网站开发多少钱,短链接还原,苏州营销型网站建设和UITableView用法类似,UITableView主要是显示按行排列的数据,UICollectionView则用在显示多行多列的数据,今天我们继续来实现app下载页面的效果。 1.先自定义UICollectionViewCell,一个cell就相当于列表中的一项了。 记得勾上&a…

和UITableView用法类似,UITableView主要是显示按行排列的数据,UICollectionView则用在显示多行多列的数据,今天我们继续来实现app下载页面的效果。

1.先自定义UICollectionViewCell,一个cell就相当于列表中的一项了。

记得勾上,这样就自动创建xib组件了

按住ctrl,鼠标连线到AppCollectionView.h文件,定义好属性

AppCollectionViewCell.h

//
//  AppCollectionViewCell.h
//  iosstudy2024
//
//  Created by figo on 2025/2/18.
//#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGIN@interface AppCollectionViewCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *appImg;
@property (weak, nonatomic) IBOutlet UILabel *appName;
@property (weak, nonatomic) IBOutlet UIButton *btnDownload;@endNS_ASSUME_NONNULL_END

AppCollectionViewCell.m

//
//  AppCollectionViewCell.m
//  iosstudy2024
//
//  Created by figo on 2025/2/18.
//#import "AppCollectionViewCell.h"@implementation AppCollectionViewCell- (void)awakeFromNib {[super awakeFromNib];// Initialization code
}@end

2.创建控制器AppsDownViewController

AppsDownViewController.h

//
//  AppsDownViewController.h
//  iosstudy2024
//
//  Created by figo on 2025/2/18.
//#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGIN@interface AppsDownViewController : UIViewController@endNS_ASSUME_NONNULL_END

AppsDownViewController.m

//
//  AppsDownViewController.m
//  iosstudy2024
//
//  Created by figo on 2025/2/18.
//
#import "AppCollectionViewCell.h"
#import "AppsDownViewController.h"@interface AppsDownViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *appUICollectionView;@end@implementation AppsDownViewController- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view from its nib.self.appUICollectionView.delegate = self;self.appUICollectionView.dataSource = self;//关联自定义AppCollectionViewCell到当前页面的UICollectionViewUINib * nib=[UINib nibWithNibName:@"AppCollectionViewCell" bundle:nil];[self.appUICollectionView registerNib:nib forCellWithReuseIdentifier:@"testCell"];//设置布局格式UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc]init];layout.scrollDirection = UICollectionViewScrollDirectionVertical;
//    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;//    CGFloat w=(UIScreen.mainScreen.bounds.size.width-3*30)/2;layout.itemSize=CGSizeMake(101, 135);
//    layout.minimumLineSpacing=5;
//    layout.minimumInteritemSpacing=5;
//    layout.sectionInset=UIEdgeInsetsMake(0, 5, 0, 5);self.appUICollectionView.collectionViewLayout=layout;self.appUICollectionView.backgroundColor=[UIColor blueColor];
}//每一项collectionViewCell
- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {AppCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"testCell" forIndexPath:indexPath];//使用tag传参@"APPName"+indexPath.item;cell.appName.text=[NSString stringWithFormat:@"APPName%ld",indexPath.item];NSString *imgPath=[[NSBundle mainBundle]pathForResource:@"star" ofType:@".png"];//照片拖入Assets件夹会找不到资源,注意需要项目下新建group命名为Supporting Files,再项目外新建文件夹比如icons,然后将图片放入icons,再将icons文件夹拖入Supporting Files才能找到,否则返回nilUIImage *uiImage=[UIImage imageWithContentsOfFile:imgPath];cell.appImg.image=uiImage;cell.btnDownload.tag=indexPath.item;//给按钮添加事件[cell.btnDownload addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];return cell;
}
-(void)btnClick:(UIButton *) btn  {NSLog(@"Selected item at index %ld", btn.tag);
}//选中某一项
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {NSLog(@"didSelectItemAtIndexPath %ld", (long)indexPath.item);
}//每个Section里面有多少项
- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {return 12;
}//定义展示的Section的个数
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{return 1;
}
@end

xib文件,就放了一个UICollectionView

3.SceneDelegate.m设置运行当前controller

//
//  SceneDelegate.m
//  iosstudy2024
//
//  Created by figo on 2024/8/5.
//#import "SceneDelegate.h"
//#import "WidgetViewController.h"
//#import "TableViewTestViewController.h"
//#import "TableViewAddressBookViewController.h"
#import "NewsViewController.h"
#import "UICollectionViewTestController.h"
#import "AppDownloadViewController.h"
#import "AppsDownViewController.h"
@interface SceneDelegate ()@end@implementation SceneDelegate- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.AppsDownViewController * viewController = [[AppsDownViewController alloc]init];self.window.rootViewController=viewController;
}- (void)sceneDidDisconnect:(UIScene *)scene {// Called as the scene is being released by the system.// This occurs shortly after the scene enters the background, or when its session is discarded.// Release any resources associated with this scene that can be re-created the next time the scene connects.// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}- (void)sceneDidBecomeActive:(UIScene *)scene {// Called when the scene has moved from an inactive state to an active state.// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.NSLog(@"%s",__func__);}- (void)sceneWillResignActive:(UIScene *)scene {// Called when the scene will move from an active state to an inactive state.// This may occur due to temporary interruptions (ex. an incoming phone call).NSLog(@"%s",__func__);
}- (void)sceneWillEnterForeground:(UIScene *)scene {// Called as the scene transitions from the background to the foreground.// Use this method to undo the changes made on entering the background.NSLog(@"%s",__func__);
}- (void)sceneDidEnterBackground:(UIScene *)scene {// Called as the scene transitions from the foreground to the background.// Use this method to save data, release shared resources, and store enough scene-specific state information// to restore the scene back to its current state.NSLog(@"%s",__func__);
}@end

http://www.dtcms.com/wzjs/391130.html

相关文章:

  • 蛇口做网站的公司论坛seo招聘
  • 湖南网站优化如何编写一个网站
  • app在哪里制作魔方优化大师官网下载
  • 装饰公司怎么做微网站百度首页网站推广多少钱一年
  • 佛山的网站建设公司新闻式软文
  • WordPress单栏二次元主题天津优化代理
  • 网站的付款链接怎么做网上推广app怎么做
  • 医院网站源码asp站长工具 seo综合查询
  • wordpress怎么打删除线班级优化大师免费下载安装
  • 医院网站建设费用宁波网络推广联系方式
  • 北京高端网站设计外包公司四川seo快速排名
  • 订阅号如何做微网站网络推广方法技巧
  • 专注营销型网站建设公司 做网站网络品牌营销
  • 做设计什么兼职网站宁波seo搜索平台推广专业
  • 开装潢公司做网站品牌营销推广方案
  • 网站建设要学哪些软件有哪些优化视频
  • 瑞昌市建设局网站b2b电商平台有哪些
  • 柳市做网站的公司北京网站优化策略
  • 商业网站制作教程免费网站在线客服软件
  • 产品包装设计网站找谁做廊坊百度关键词优化
  • 做网站公司共有几处密码千万不要学网络营销
  • 网站上的销售怎么做的互联网产品运营推广方案
  • 诚信宁津建设网站谷歌seo优化推广
  • 企业微信网站怎么做百度小说风云榜2022
  • 网站改版后新版前台如何跟旧版后台链接上海网络营销seo
  • 小企网站建设解决方案免费seo优化
  • 旅游推荐网站怎么做企业网站有哪些类型
  • 嘉兴型网站系统总部推广渠道有哪些平台
  • 网站建设专题会议seo推广效果
  • 网站建设的什么是网站建设的第一阶段品牌广告视频