最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS購物分類模塊的實(shí)現(xiàn)方案

 更新時(shí)間:2016年02月22日 09:00:08   投稿:lijiao  
這篇文章主要為大家詳細(xì)介紹了iOS購物分類模塊的實(shí)現(xiàn)方案,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例分享了iOS購物分類模塊的實(shí)現(xiàn)方案,供大家參考,具體內(nèi)容如下

啟動(dòng)
在AppDelegate中創(chuàng)建主視圖控制器。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Override point for customization after application launch.
  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  // Override point for customization after application launch.
  self.window.backgroundColor = [UIColor whiteColor];
  [self.window makeKeyAndVisible];
      
  Basetabarcontroller*base=[[Basetabarcontroller alloc]init];
      
  self.window.rootViewController=base;
      
  return YES;
    
}

UI框架設(shè)計(jì)

Basetabbarcontroller基于UITabBarController,作為主視圖控制器。
頭文件如下:

@interface Basetabarcontroller : UITabBarController
    
@end

實(shí)現(xiàn)文件中主要做了2點(diǎn):創(chuàng)建視圖控制器ClassViewController,并將它設(shè)置到新創(chuàng)建的創(chuàng)建導(dǎo)航控制器中。

- (void)viewDidLoad {
  [super viewDidLoad];
  self.tabBar.tintColor = [UIColor redColor];
  // self.tabBar.barTintColor = [UIColor blackColor];
      
   ClassViewController*classList=[[ClassViewController alloc]init];
  //classList.title=@"分類";
     
     
  [self addChildViewController:classList title:@"分類" image:@""];
     
  UIButton *menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  menuBtn.frame = CGRectMake(0, 0, 20, 18);
  [menuBtn setBackgroundImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal];
  [menuBtn addTarget:self action:@selector(openOrCloseLeftList) forControlEvents:UIControlEventTouchUpInside];
  self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:menuBtn];
  //self.tabBar.barTintColor = [UIColor redColor];
}
- (void)addChildViewController:(UIViewController *)childController title:(NSString *)title image:(NSString *)image{
      
  UINavigationController *childVC = [[UINavigationController alloc]initWithRootViewController:childController];
  childVC.tabBarItem.title = title;
   childVC.tabBarItem.image = [UIImage imageNamed:image];
  childVC.navigationBar.barTintColor = [UIColor whiteColor];
       
  [self addChildViewController:childVC];
      
    
}

主要的界面視圖控制器定義:

@interface ClassViewController : UIViewController
   
@end

實(shí)現(xiàn)文件中:

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view.
     
   
  UIBarButtonItem *searchBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(searchBarButtonItemAction)];
  self.navigationItem.rightBarButtonItem = searchBarButtonItem;
    [self setdata];
  [self setimage];
  [self setdeatil];
   
     
  _a=1;
  _b=1;
  _segement=[[UISegmentedControl alloc]initWithItems:@[@"攻略",@"詳情"]];
  _segement.frame=CGRectMake(90, 20, kwidth-180, 30);
  _segement.tintColor=[UIColor blackColor];
  _segement.selectedSegmentIndex=0;
  [_segement addTarget:self action:@selector(changevalue:) forControlEvents:(UIControlEventValueChanged)];
  self.navigationItem.titleView =_segement;
   self.scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kwidth, KHeight)];
  _scrollview.directionalLockEnabled=YES;
  _scrollview.contentSize=CGSizeMake(kwidth*2, KHeight);
  _scrollview.delegate=self;
     
     
  [self.view addSubview:self.scrollview];
  UICollectionViewFlowLayout*flow=[[UICollectionViewFlowLayout alloc]init];
    //列距
  flow.minimumInteritemSpacing=20;
     
  //行距
  flow.minimumLineSpacing=40;
    //分區(qū)內(nèi)邊距
  flow.sectionInset=UIEdgeInsetsMake(0, 20, 20, 20);
    CGFloat totalwidth=self.view.frame.size.width;
     
  CGFloat itemwidth=(totalwidth-2*20-3*20)/4.0;
     
  CGFloat itemheight=itemwidth;
     
  flow.itemSize=CGSizeMake(itemwidth, itemheight);
     
  flow.headerReferenceSize=CGSizeMake(0, 40);
     
  //滾動(dòng)方向
  flow.scrollDirection= UICollectionViewScrollDirectionVertical;
  ;
     
  //區(qū)頭大小
  flow.headerReferenceSize=CGSizeMake(0, 100);
     
  _collection=[[UICollectionView alloc]initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:flow];
  _collection.backgroundColor=[UIColor whiteColor];
  _collection.tag=1;
  _Srr=@[@"1",@"s",@"2",@"r"];
  for (NSString*St in _Srr) {
    [_collection registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:St];}
  //設(shè)置 數(shù)據(jù)源 和代理
  _collection.dataSource=self;
  _collection.delegate=self;
  [_collection registerClass:[ClassCollectionViewCell class] forCellWithReuseIdentifier:@"mycell"];
  // _collection.backgroundColor=[UIColor yellowColor];
  _collection.directionalLockEnabled=YES;
     
  [self.scrollview addSubview:_collection];
  UIView*view=[[UIView alloc]initWithFrame:CGRectMake(kwidth, 0, kwidth, 30)];
  // view.backgroundColor = [UIColor whiteColor];
  UIButton*label=[UIButton buttonWithType:(UIButtonTypeSystem)];
  label.frame=CGRectMake(0, 20, 200, 14) ;
  [label setTitle:@"選禮神器" forState:(UIControlStateNormal)];
  [label addTarget:self action:@selector(xuan) forControlEvents:(UIControlEventTouchUpInside)];
  [view addSubview:label];
  [self.scrollview addSubview:view];

 網(wǎng)絡(luò)數(shù)據(jù)封裝
基于NFNetworking,封裝了3個(gè)接口

@interface LORequestManger : NSObject
   
+ (void)POST:(NSString *)URL params:(NSDictionary * )params success:(void (^)(id response))success
   failure:(void (^)(AFHTTPRequestOperation *operation,NSError *error))Error;
   
   
+ (void)GET:(NSString *)URL
  success:(void (^)(id response))success
  failure:(void (^)(AFHTTPRequestOperation *operation,NSError *error))Error;
   
+ (void)UPLOADIMAGE:(NSString *)URL
       params:(NSDictionary *)params
    uploadImage:(UIImage *)image
      success:(void (^)(id response))success
      failure:(void (^)(AFHTTPRequestOperation *operation,NSError *error))Error;
   
@end

實(shí)現(xiàn)文件:

#import "LORequestManger.h"
#define serverUrl @"http://192.168.1.1:8080/jiekou"
   
@implementation LORequestManger
   
   
   
+ (void)POST:(NSString *)URL params:(NSDictionary * )params success:(void (^)(id response))success
   failure:(void (^)(AFHTTPRequestOperation *operation,NSError *error))Error
{
  // 創(chuàng)建請求管理者
  AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
     
  // 請求超時(shí)時(shí)間
   
  manager.requestSerializer.timeoutInterval = 30;
  NSString *postStr = URL;
  if (![URL hasPrefix:@"http"]) {
       
    postStr = [NSString stringWithFormat:@"%@%@", serverUrl,URL] ;
  }
  NSMutableDictionary *dict = [params mutableCopy];
     
     
  // 發(fā)送post請求
  [manager POST:postStr parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
       
    // 請求成功
    NSDictionary *responseDict = (NSDictionary *)responseObject;
    success(responseDict);
       
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {// 請求失敗
    Error( operation,error);
       
  }];
   
   
}
   
+ (void)GET:(NSString *)URL
  success:(void (^)(id response))success
  failure:(void (^)(AFHTTPRequestOperation *operation,NSError *error))Error
{
  // 獲得請求管理者
  AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] init];
  manager.requestSerializer = [AFJSONRequestSerializer serializer];
  [manager.requestSerializer setHTTPShouldHandleCookies:NO];
  manager.requestSerializer.timeoutInterval = 30;
  NSString *getStr = URL;
//  NSLog(@"getStr======%@",getStr);
  if (![URL hasPrefix:@"http"]) {
       
    getStr = [NSString stringWithFormat:@"%@%@", serverUrl,URL] ;
  }
   
     
  // 發(fā)送GET請求
  [manager GET:getStr parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
//    NSLog(@"getStr------------%@",getStr);
    NSDictionary *responseDict = (NSDictionary *)responseObject;
      
      success(responseDict);
   
       
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    if (!operation.responseObject) {
      NSLog(@"網(wǎng)絡(luò)錯(cuò)誤");
    }
    Error( operation,error);
  }];
   
     
}
   
+ (void)UPLOADIMAGE:(NSString *)URL
       params:(NSDictionary *)params
    uploadImage:(UIImage *)image
      success:(void (^)(id response))success
      failure:(void (^)(AFHTTPRequestOperation *operation,NSError *error))Error
{
  // 創(chuàng)建請求管理者
  AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
     
  manager.requestSerializer = [AFJSONRequestSerializer serializer];
  manager.responseSerializer = [AFJSONResponseSerializer serializer];
  manager.requestSerializer.timeoutInterval = 30;
  //  [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  //
  //  [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
     
  NSString *postStr = [NSString stringWithFormat:@"%@%@", serverUrl,URL] ;
  NSMutableDictionary *dict = [params mutableCopy];
   
  [manager POST:postStr parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    NSData *imageData = UIImageJPEGRepresentation(image, 0.1);
    [formData appendPartWithFileData:imageData name:@"img" fileName:@"head.jpg" mimeType:@"image/jpeg"];
       
  } success:^(AFHTTPRequestOperation *operation, id responseObject) {
   
    NSDictionary *responseDict = (NSDictionary *)responseObject;
        success(responseDict);
    
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    Error( operation,error);
       
  }];
   
   
   
}

效果:

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

相關(guān)文章

  • IOS 集成微信支付功能的實(shí)現(xiàn)方法

    IOS 集成微信支付功能的實(shí)現(xiàn)方法

    這篇文章主要介紹了IOS 集成微信支付功能的實(shí)現(xiàn)方法的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下
    2017-09-09
  • iOS高仿微信相冊界面翻轉(zhuǎn)過渡動(dòng)畫效果

    iOS高仿微信相冊界面翻轉(zhuǎn)過渡動(dòng)畫效果

    在圖片界面點(diǎn)擊右下角的查看評論會(huì)翻轉(zhuǎn)到評論界面,評論界面點(diǎn)擊左上角的返回按鈕會(huì)反方向翻轉(zhuǎn)回圖片界面,真正的實(shí)現(xiàn)方法,與傳統(tǒng)的導(dǎo)航欄過渡其實(shí)只有一行代碼的區(qū)別,下面小編通過本文給大家介紹下ios高仿微信相冊界面翻轉(zhuǎn)過渡動(dòng)畫效果,一起看看吧
    2016-11-11
  • IOS 關(guān)鍵字const 、static、extern詳解

    IOS 關(guān)鍵字const 、static、extern詳解

    這篇文章主要介紹了IOS 關(guān)鍵字const 、static、extern詳解的相關(guān)資料,這里對關(guān)鍵字如何使用,及在IOS開發(fā)中的意義做了詳解,需要的朋友可以參考下
    2016-11-11
  • iOS獲取驗(yàn)證碼倒計(jì)時(shí)效果

    iOS獲取驗(yàn)證碼倒計(jì)時(shí)效果

    這篇文章主要為大家詳細(xì)介紹了iOS獲取驗(yàn)證碼倒計(jì)時(shí)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • ios 單利的完整使用實(shí)例 及銷毀 宏定義

    ios 單利的完整使用實(shí)例 及銷毀 宏定義

    下面小編就為大家分享一篇ios 單利的完整使用實(shí)例 及銷毀 宏定義,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • iOS輸入框的字?jǐn)?shù)統(tǒng)計(jì)/最大長度限制詳解

    iOS輸入框的字?jǐn)?shù)統(tǒng)計(jì)/最大長度限制詳解

    在開發(fā)中經(jīng)常會(huì)遇到鍵盤輸入的字符長度的限制,下面這篇文章主要給大家介紹了關(guān)于iOS輸入框的字?jǐn)?shù)統(tǒng)計(jì)/最大長度限制的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-06-06
  • iOS實(shí)現(xiàn)微信朋友圈視頻截取功能

    iOS實(shí)現(xiàn)微信朋友圈視頻截取功能

    這篇文章主要介紹了iOS實(shí)現(xiàn)微信朋友圈視頻截取功能,微信使用非常普遍,功能也很強(qiáng)大,不知道大家對微信朋友圈視頻截取功能有沒有了解,下面腳本之家小編給大家?guī)碓斀饨榻B,感興趣的朋友一起看看吧
    2018-07-07
  • 一個(gè)方法搞定iOS下拉放大及上推縮小

    一個(gè)方法搞定iOS下拉放大及上推縮小

    在很多的APP中,我們可以看到一個(gè)列表頂部的圖片會(huì)隨著下拉會(huì)放大,隨著上推縮小。這樣的效果沒能給定一個(gè)固有名詞,現(xiàn)在本文介紹使用代碼實(shí)現(xiàn)這樣的效果,代碼量很少,容易理解。當(dāng)然實(shí)現(xiàn)效果是很好的。
    2016-07-07
  • 快速解決低版本Xcode不支持高版本iOS真機(jī)調(diào)試的問題方法

    快速解決低版本Xcode不支持高版本iOS真機(jī)調(diào)試的問題方法

    這篇文章主要介紹了快速解決低版本Xcode不支持高版本iOS真機(jī)調(diào)試的問題,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-02-02
  • React Native搭建iOS開發(fā)環(huán)境

    React Native搭建iOS開發(fā)環(huán)境

    React Native的門檻不管是對于前端開發(fā)者還是移動(dòng)端開發(fā)者來說都是很高的,既要懂原生又要懂js,技術(shù)棧是相當(dāng)長的。但是沒有關(guān)系,下面我們一步步來學(xué)習(xí),慢慢成長吧!
    2016-09-09

最新評論

浦北县| 阿勒泰市| 岳池县| 临武县| 嘉荫县| 老河口市| 葵青区| 贡山| 都安| 呼伦贝尔市| 高邑县| 沽源县| 栾城县| 景洪市| 通山县| 柳江县| 昆明市| 灵璧县| 奇台县| 陈巴尔虎旗| 青铜峡市| 开阳县| 仙居县| 银川市| 伊通| 崇阳县| 元朗区| 宁德市| 云南省| 开鲁县| 东平县| 兴安盟| 嘉鱼县| 松原市| 娄底市| 南和县| 汶川县| 阿图什市| 正蓝旗| 灵宝市| 和硕县|