欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS項目開發(fā)--實現(xiàn)類似淘寶詳情頁面

 更新時間:2016年11月14日 10:10:27   作者:小兵快跑  
本篇文章主要介紹了iOS實現(xiàn)類似淘寶詳情頁面,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

前段時間公司在研發(fā)一個電商項目,趁現(xiàn)在有時間把其中的知識點整理整理。

項目的商品詳情頁面當(dāng)時是仿制淘寶的,用到的第三方庫是MJRefresh,上拉操作和下拉操作的刷新效果是把MJRefresh刷新效果從新建個分類封裝了一下,感謝杰哥!??!

基本思路:

1、設(shè)置一個 UIScrollView 作為視圖底層,并且設(shè)置分頁為兩頁

2、然后在第一個分頁上添加一個 UITableView 并且設(shè)置表格能夠上提加載(上拉操作即為讓視圖滾動到下一頁)

3、 在第二個分頁上添加一個 UIScrollView 并且設(shè)置能有下拉刷新操作(下拉操作即為讓視圖滾動到上一頁)

4、第二個分頁UIScrollView添加子UIView,一般式商品的圖文詳情、產(chǎn)品參數(shù)、店鋪等

5、Demo只提供簡單的思路,項目具體實現(xiàn)基本相同

 /** 封裝刷新 MJRefresh */
#import "QRG_MJRefreshAutoFooter.h"
#import "QRG_MJRefreshNormalHeader.h"

#import "CollectionViewCell.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height

#define ARCCOLOR (arc4random() % 255/256.0)
#import "ViewController.h"

主要代碼

- (void)viewDidLoad {
 [super viewDidLoad];

 /** 底層view*/
 UIScrollView *mainScrollView = [[UIScrollView alloc] init];
 mainScrollView.scrollEnabled = NO;
 mainScrollView.frame = CGRectMake(0, 0, WIDTH, HEIGHT);
 mainScrollView.contentSize = CGSizeMake(WIDTH, HEIGHT * 2);
 mainScrollView.backgroundColor = [UIColor greenColor];
 mainScrollView.pagingEnabled = YES;
 mainScrollView.bounces = YES;
 [self.view addSubview:mainScrollView];
 /** 第一頁面 table*/ 
 OneTable = [[UITableView alloc] init];
 OneTable.frame = CGRectMake(0,0, WIDTH, HEIGHT - 64);
 OneTable.separatorColor = [UIColor greenColor];
 OneTable.delegate = self;
 OneTable.dataSource = self;
 OneTable.rowHeight = 80;
 [mainScrollView addSubview:OneTable];
 /** 第二頁面 scrollView*/  
 UIScrollView *TwoScrollView = [[UIScrollView alloc] init];
 TwoScrollView.frame = CGRectMake(0, HEIGHT + 64, WIDTH, HEIGHT - 64);
 TwoScrollView.contentSize = CGSizeMake(WIDTH * 3, HEIGHT - 64);
 TwoScrollView.backgroundColor = [UIColor cyanColor];
 TwoScrollView.pagingEnabled = YES;
 TwoScrollView.bounces = NO;

 [mainScrollView addSubview:TwoScrollView];

 /** 第二頁面 table*/ 

 TwoTable = [[UITableView alloc] init];
 TwoTable.frame = CGRectMake(WIDTH, 0, WIDTH, HEIGHT - 64);
 TwoTable.separatorColor = [UIColor redColor];
 TwoTable.delegate = self;
 TwoTable.dataSource = self;
 [TwoScrollView addSubview:TwoTable];

 /** 第二頁面 UICollectionView*/ 
 UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
 [flow setScrollDirection:UICollectionViewScrollDirectionVertical];

 UICollectionView *TwoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64) collectionViewLayout:flow];
 TwoCollectionView.backgroundColor = [UIColor lightTextColor];
 TwoCollectionView.delegate = self;
 TwoCollectionView.dataSource = self;
 [TwoScrollView addSubview:TwoCollectionView];

// [TwoCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Coll"];

 [TwoCollectionView registerNib:[UINib nibWithNibName:@"CollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"Coll"];


 //設(shè)置UITableView 上拉加載
 OneTable.mj_footer = [QRG_MJRefreshAutoFooter footerWithRefreshingBlock:^{
  //上拉,執(zhí)行對應(yīng)的操作---改變底層滾動視圖的滾動到對應(yīng)位置
  //設(shè)置動畫效果
  [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionLayoutSubviews animations:^{
   //   self.scrollV.contentOffset = CGPointMake(0, IPHONE_H);
   [mainScrollView setContentOffset:CGPointMake(0, HEIGHT)];

  } completion:^(BOOL finished) {
   //結(jié)束加載
   [OneTable.mj_footer endRefreshing];
  }];


 }];

 //設(shè)置TwoCollectionView 有下拉操作
 TwoCollectionView.mj_header = [QRG_MJRefreshNormalHeader headerWithRefreshingBlock:^{
  //下拉執(zhí)行對應(yīng)的操作
  //  self.scrollV.contentOffset = CGPointMake(0,0);
  [UIView animateWithDuration:1 animations:^{
   [mainScrollView setContentOffset:CGPointMake(0, - 64)];

  }];

  //結(jié)束加載
  [TwoCollectionView.mj_header endRefreshing];
 }];

 //設(shè)置TwoTable 有下拉操作
 TwoTable.mj_header = [QRG_MJRefreshNormalHeader headerWithRefreshingBlock:^{
  //下拉執(zhí)行對應(yīng)的操作
  //  self.scrollV.contentOffset = CGPointMake(0,0);

  [UIView animateWithDuration:1 animations:^{
   [mainScrollView setContentOffset:CGPointMake(0, - 64)];

  }];  
  //結(jié)束加載
  [TwoTable.mj_header endRefreshing];
 }];


}

pragma mark---------Delegate

#pragma mark---------tableDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
 CGFloat height;
  if([tableView isEqual:OneTable])
  {
   height = 80;
  }else
  {
   return 120;
  }
 return height;


}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
 return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 static NSString *Cell = @"Cell";
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Cell];

 if(!cell)
 {
  cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
 }

 cell.textLabel.text = [NSString stringWithFormat:@"%ld--askl",indexPath.row];
 cell.imageView.image = [UIImage imageNamed:@"6"];
 return cell;

}

#pragma mark---------CollectionViewDelegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
 return 20;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
 return CGSizeMake(150, 100);
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
 static NSString *Coll = @"Coll";

 CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:Coll forIndexPath:indexPath];

// cell.backgroundColor =[UIColor greenColor];
 return cell;
}

 

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS應(yīng)用開發(fā)中使用NSLocale類實現(xiàn)對象信息的本地化

    iOS應(yīng)用開發(fā)中使用NSLocale類實現(xiàn)對象信息的本地化

    這篇文章主要介紹了iOS應(yīng)用開發(fā)中使用NSLocale類實現(xiàn)對象信息的本地化的方法,能夠?qū)r間和貨幣等格式化為與系統(tǒng)本地設(shè)置相同的偏好,需要的朋友可以參考下
    2016-05-05
  • android中UIColletionView瀑布流布局實現(xiàn)思路以及封裝的實現(xiàn)

    android中UIColletionView瀑布流布局實現(xiàn)思路以及封裝的實現(xiàn)

    本篇文章主要介紹了android中UIColletionView瀑布流布局實現(xiàn)思路以及封裝的實現(xiàn),具有一定的參考價值,有興趣的可以了解一下。
    2017-02-02
  • 10個非常實用的iOS小技巧

    10個非常實用的iOS小技巧

    這篇文章主要為大家詳細(xì)介紹了10個非常實用的iOS小技巧,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • iOS中字符串換行的實現(xiàn)方法

    iOS中字符串換行的實現(xiàn)方法

    大家應(yīng)該都有所體會,單行字符數(shù)過多會影響美觀,所以下面這篇文章主要給大家介紹了關(guān)于iOS中字符串換行的實現(xiàn)方法,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2018-07-07
  • iOS Gif圖片展示N種方式(原生+第三方)

    iOS Gif圖片展示N種方式(原生+第三方)

    這篇文章主要介紹了iOS Gif圖片展示N種方式,包括原生、第三方方式展示,感興趣的小伙伴們可以參考一下
    2016-03-03
  • iOS項目開發(fā)--實現(xiàn)類似淘寶詳情頁面

    iOS項目開發(fā)--實現(xiàn)類似淘寶詳情頁面

    本篇文章主要介紹了iOS實現(xiàn)類似淘寶詳情頁面,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-11-11
  • iOS push側(cè)滑返回功能實現(xiàn)方法

    iOS push側(cè)滑返回功能實現(xiàn)方法

    這篇文章主要為大家詳細(xì)介紹了iOS push側(cè)滑返回功能實現(xiàn)方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • iOS中多線程的入門使用教程(Swift)

    iOS中多線程的入門使用教程(Swift)

    這篇文章主要給大家介紹了關(guān)于iOS中多線程入門使用的相關(guān)資料,一個進(jìn)程中可以開啟多條線程,每條線程可以并行執(zhí)行不同的任務(wù),本文通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2021-11-11
  • iOS中WKWebView白屏問題的分析與解決

    iOS中WKWebView白屏問題的分析與解決

    最近在工作中遇到了WKWebView白屏的問題,所以這篇文章主要給大家介紹了關(guān)于iOS中WKWebView白屏問題的分析與解決方法,文中通過示例代碼介紹的非常詳細(xì),對同樣遇到這個問題的朋友具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-10-10
  • iOS 微信分享功能簡單實現(xiàn)

    iOS 微信分享功能簡單實現(xiàn)

    本文介紹了iOS 微信分享功能的實現(xiàn)步驟與方法,具有一定的參考作用。下面跟著小編一起來看下吧
    2017-01-01

最新評論