课程:'从0开发一款iOS APP'

一、课程简介

课程链接
基础语法入门

20191019150826.png

3.常见APP类型与技术栈

【常见APP类型】
20191019151128.png

【技术栈】
20191019151258.png

【辅助软件】
20191019151745.png

二、基本界面

5、MVC模式

20191019152245.png

6、视图UIView

20191019152345.png
【布局图放这里】

7、UIView的生命周期

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 重载生命周期四个主要函数
// 添加到父View
- (void)willMoveToSuperview:(nullable UIView *)newSuperview
{
[super willMoveToSuperview:newSuperview];
}

- (void)didMoveToSuperview
{
[super didMoveToSuperview];
}
// 父View与当前View添加到Window
- (void)willMoveToWindow:(nullable UIWindow *)newWindow
{
[super willMoveToWindow:newWindow];
}

- (void)didMoveToWindow
{
[super didMoveToWindow];
}

8、UIViewController

9、UITabBarController

10、UINavigationController

UITableViewCell复用逻辑

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// 获取cell阶段:
// 首先去系统复用回收池中取cell;取到之后执行后续代码,重新设置cell的内容。 【好处:数据量大时,高效实现滚动列表】
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"id"];
// 如果取不到复用cell,就重新创建一个cell
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"id"];
}
cell.textLabel.text = @"主标题";
cell.detailTextLabel.text = @"副标题";
cell.imageView.image = [UIImage imageNamed:@"icon.bundle/video@2x.png"];
return cell;
// cell滚出阶段:
// cell滚出屏幕可见区域后,系统自动将相同ID的cell放到系统回收池
}

UICollectionViewCell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];

UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:flowLayout];

collectionView.dataSource = self;
collectionView.delegate = self;
// 重用cell注册
[collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"UICollectionViewCell"];

[self.view addSubview:collectionView];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 200;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"UICollectionViewCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor redColor];
return cell;
}

UIScrollView的代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// NSLog(@"scrollViewDidScroll - %@", @(scrollView.contentOffset.x));
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
NSLog(@"scrollViewWillBeginDragging");
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
NSLog(@"scrollViewDidEndDragging");
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
NSLog(@"scrollViewWillBeginDecelerating");
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"scrollViewDidEndDecelerating");
}

##

三、基础功能

四、功能扩展完善

--------- 本文结束 感谢您的阅读 ---------
0%
;