求好心人帮忙看下6.69C里dota屠夫钩子子的...

iOS 问题:问题一:怎么实现加入购物车并且去购物车中结算的功能啊?求好心人帮助我一下,有点急啊,我是刚入行的。谢谢了
问题二:我用for循环在scrollView中加入了三个TableView,并且给每个TableView一个tag值,因为在后面需要识别出是哪个tableview,但是tag值总是显示的是最后一个tableview的tag值,不知道怎么解决了。 -
问题一:怎么实现加入购物车并且去购物车中结算的功能啊?求好心人帮助我一下,有点急啊,我是刚入行的。谢谢了
问题二:我用for循环在scrollView中加入了三个TableView,并且给每个TableView一个tag值,因为在后面需要识别出是哪个tableview,但是tag值总是显示的是最后一个tableview的tag值,不知道怎么解决了。
共有 5 个回答
问题一,你是要做支付功能么?还是只是加入购物车,然后在购物车里面看到之前加入的商品?
问题二,建议把代码贴出来。否则无法知道你是怎么做的。
登录后方可回复
问题一:先加入购物车,然后在购物车里面看到之前加入的商品,然后在购物车中有个结算按钮,单击按钮进行支付
问题二:代码如下:
#import "FirstViewController.h"
#import "ShangPinListCell.h"
#import "ShangPinDetailViewController.h"
#import "UIImageView+WebCache.h"
#import "UIImageView+WebCache.h"
#import "FirstViewItem.h"
#import "ShangPinCategoryItem.h"
@implementation FirstViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
UITabBarItem *barItem = [[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"blue-home-icon.png"] tag:100];
self.tabBarItem = barI
[barItem release];
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
-(void)createNav
UIBarButtonItem *itemLeft = [[UIBarButtonItem alloc]initWithTitle:@"切换区域" style:UIBarButtonItemStylePlain target:self action:@selector(ClickedButtonLeft:)];
self.navigationItem.leftBarButtonItem = itemL
[itemLeft release];
UIButton *buttonRight = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"playback_reload.png"]];
imageView.frame = CGRectMake(7, 5, 15, 15);
buttonRight.frame = CGRectMake(0, 0, 30,25);
[buttonRight addTarget:self action:@selector(ClickedButtonRight:) forControlEvents:UIControlEventTouchUpInside];
[buttonRight addSubview:imageView];
UIBarButtonItem *buttonRightBar = [[UIBarButtonItem alloc]initWithCustomView:buttonRight];
self.navigationItem.rightBarButtonItem = buttonRightB
- (void)viewDidLoad
[super viewDidLoad];
[self createNav];
dataArray = [[NSMutableArray alloc]init];
dataArray1 = [[NSMutableArray alloc]init];
dataArray2 = [[NSMutableArray alloc]init];
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ChatBackground_00.jpg"]];
imageView.frame = CGRectMake(0, 0, 320, 380);
[self.view addSubview:imageView];
[imageView release];
UISearchBar *searchBar = [[UISearchBar alloc]init];
searchBar.frame = CGRectMake(0, 0, 320, 44);
searchBar.barStyle = UIBarStyleB
searchBar.placeholder = @"搜索商品";
[self.view addSubview:searchBar];
UISearchDisplayController *dis = [[UISearchDisplayController alloc]initWithSearchBar:searchBar contentsController:self];
dis.searchResultsDelegate =
dis.searchResultsDataSource =
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"activated_btn.png"] forBarMetrics:UIBarMetricsDefault];
self.navigationItem.title = @"首页";
areasViewController = [[RootViewController alloc]init];
//创建滚动视图
CGRect frameScrollView = [[UIScreen mainScreen]bounds];
frameScrollView.origin.y +=44;
frameScrollView.size.height -=70+44;
mScrollView = [[UIScrollView alloc]initWithFrame:frameScrollView];
mScrollView.contentSize = CGSizeMake(320*3, frameScrollView.size.height);
mScrollView.showsHorizontalScrollIndicator = NO;
mScrollView.pagingEnabled = YES;
for (int i = 0; i & 3; i++)
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(320*i, 0, 320, 110)];
if (i == 0)
[imageView setImageWithURL:[NSURL URLWithString:@"8a20aafc6_600.jpg" class="c4alink" target="_blank"&8a20aafc6_600.jpg"]];
[imageView setImageWithURL:[NSURL URLWithString:@"8a20aaf240d8aa.jpg" class="c4alink" target="_blank"&8a20aaf240d8aa.jpg"]];
[imageView setImageWithURL:[NSURL URLWithString:@"8a20aaf240dc72c.jpg" class="c4alink" target="_blank"&8a20aaf240dc72c.jpg"]];
pageCtrl = [[UIPageControl alloc]initWithFrame:CGRectMake(130+320*i, 0, 60, 20)];
[pageCtrl setNumberOfPages:3];
[mScrollView addSubview:pageCtrl];
CGRect frame = [[UIScreen mainScreen]bounds];
frame.origin.y += 110;
frame.origin.x +=320*i;
frame.size.height = 215;
mTableView = [[UITableView alloc]initWithFrame:frame style:UITableViewStyleGrouped];
mTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleW
mTableView.delegate =
mTableView.dataSource =
mTableView.backgroundColor = [UIColor clearColor];
mTableView.tag = i+100;
[mScrollView addSubview:mTableView];
[mScrollView addSubview:imageView];
[self.view addSubview:mScrollView];
httpRequest = [[QFHttpRequest alloc]init];
httpRequest.delegate =
httpRequest.method = @selector(downloadComplete:);
[httpRequest requestWithUrl:@""];
-(void)downloadComplete:(QFHttpRequest*)request
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:request.downloadData options:NSJSONReadingMutableContainers error:nil];
for (int i= 0; i&3; i++)
UITableView *tempTable = (UITableView *)[mScrollView viewWithTag:i+100];
NSArray *array = [dict objectForKey:@"indexFloorModules"];
NSDictionary *subDict = [array objectAtIndex:2];
NSArray *subArray = [subDict objectForKey:@"specialOffers"];
NSDictionary *subDict1 = [subArray objectAtIndex:0];
strTitle1 = [subDict1 objectForKey:@"name"];
NSArray *productArray = [subDict1 objectForKey:@"products"];
for (NSDictionary *dic in productArray)
ShangPinCategoryItem *item = [[ShangPinCategoryItem alloc]init];
item.detailName = [dic objectForKey:@"name"];
item.detailSize = [dic objectForKey:@"size"];
item.detailPrice = [NSString stringWithFormat:@"¥%@",[dic objectForKey:@"price"]];
item.detailMarketPrice = [NSString stringWithFormat:@"¥%@",[dic objectForKey:@"marketPrice"]];
NSDictionary *dictionary = [dic objectForKey:@"featurePicture"];
item.detailPicture60 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size60"]];
item.detailPicture180 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size180"]];
item.detailPicture360 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size600"]];
[dataArray addObject:item];
NSLog(@"dataArray==%@",dataArray);
NSMutableArray *mArray = [[NSMutableArray alloc]initWithCapacity:0];
NSArray *array = [dict objectForKey:@"indexFloorModules"];
NSDictionary *subDict = [array objectAtIndex:3];
NSArray *subArray = [subDict objectForKey:@"specialOffers"];
for (NSDictionary *subDict1 in subArray)
NSArray *productArray = [subDict1 objectForKey:@"products"];
for (NSDictionary *dic in productArray)
ShangPinCategoryItem *item = [[ShangPinCategoryItem alloc]init];
item.detailName = [dic objectForKey:@"name"];
item.detailSize = [dic objectForKey:@"size"];
item.detailPrice = [NSString stringWithFormat:@"¥%@",[dic objectForKey:@"price"]];
item.detailMarketPrice = [NSString stringWithFormat:@"¥%@",[dic objectForKey:@"marketPrice"]];
NSDictionary *dictionary = [dic objectForKey:@"featurePicture"];
item.detailPicture60 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size60"]];
item.detailPicture180 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size180"]];
item.detailPicture360 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size600"]];
[mArray addObject:item];
[dataArray1 addObject:mArray];
NSLog(@"dataArray1==%@",dataArray1);
NSArray *array = [dict objectForKey:@"indexFloorModules"];
NSDictionary *subDict = [array objectAtIndex:4];
NSArray *subArray = [subDict objectForKey:@"specialOffers"];
NSDictionary *subDict1 = [subArray objectAtIndex:0];
NSArray *productArray = [subDict1 objectForKey:@"products"];
for (NSDictionary *dic in productArray)
ShangPinCategoryItem *item = [[ShangPinCategoryItem alloc]init];
item.detailName = [dic objectForKey:@"name"];
item.detailSize = [dic objectForKey:@"size"];
item.detailPrice = [NSString stringWithFormat:@"%@",[dic objectForKey:@"price"]];
item.detailMarketPrice = [NSString stringWithFormat:@"%@",[dic objectForKey:@"marketPrice"]];
NSDictionary *dictionary = [dic objectForKey:@"featurePicture"];
item.detailPicture60 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size60"]];
item.detailPicture180 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size180"]];
item.detailPicture360 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size600"]];
[dataArray2 addObject:item];
NSLog(@"dataArray2==%@",dataArray2);
[tempTable reloadData];
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
CGFloat aWidth = scrollView.frame.size.
NSInteger curPageView = floor(scrollView.contentOffset.x/aWidth);//获得当前页数
[pageCtrl setCurrentPage:curPageView];
-(void)viewWillAppear:(BOOL)animated
UIColor *color = [[UIColor alloc]initWithRed:0 green:0.1 blue:0.1 alpha:0.1];
self.navigationController.navigationBar.tintColor =
-(void)ClickedButtonLeft:(UIBarButtonItem*)button
[self presentViewController:areasViewController animated:YES completion:nil];
-(void)ClickedButtonRight:(UIBarButtonItem*)button
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
if (mTableView.tag == 101)
NSLog(@"第一个tableview");
return [dataArray1 count];
if (mTableView.tag == 100)
NSLog(@"第二个tableview");
return [dataArray count];
NSLog(@"第3个tableview");
return [dataArray2 count];
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
if (tableView.tag == 101)
NSLog(@"第二个tableview的组数");
NSLog(@"其他tableview的组数");
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
return 75;
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
if (mTableView.tag == 100)
NSLog(@"1");
return strTitle1;
if(mTableView.tag == 101)
NSLog(@"2");
if (section==0)
stringTitle = @"百事系列";
if (section==1)
stringTitle = @"可口系列饮料";
if (section==2)
stringTitle = @"矿泉水";
return stringT
NSLog(@"3");
stringTitle = @"零食天堂";
return stringT
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *cellName = @"ID";
ShangPinListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
if (cell == nil)
cell = [[[NSBundle mainBundle]loadNibNamed:@"ShangPinCell" owner:self options:nil]lastObject];
cell.selectionStyle = UITableViewCellSelectionStyleN
if (mTableView.tag == 100)
NSLog(@"++++++++++++++++");
ShangPinCategoryItem *item = [dataArray objectAtIndex:indexPath.row];
cell.NameLabel.text = item.detailN
cell.priceLabel.text = [NSString stringWithFormat:@"¥%@",item.detailPrice];
cell.priceLabel.textColor = [UIColor redColor];
//cell.volLabel.text = item.detailS
[cell.imageView setImageWithURL:[NSURL URLWithString:item.detailPicture60] placeholderImage:[UIImage imageNamed:@"Placeholder"]];
if (mTableView.tag == 101)
NSLog(@"[][][][][][]");
ShangPinCategoryItem *item = [[dataArray1 objectAtIndex:indexPath.section]objectAtIndex:indexPath.row];
cell.NameLabel.text = item.detailN
cell.priceLabel.text = [NSString stringWithFormat:@"¥%@",item.detailPrice];
cell.priceLabel.textColor = [UIColor redColor];
//cell.volLabel.text = item.detailS
[cell.imageView setImageWithURL:[NSURL URLWithString:item.detailPicture60] placeholderImage:[UIImage imageNamed:@"Placeholder"]];
if(mTableView.tag == 102)
NSLog(@"hello");
ShangPinCategoryItem *item = [dataArray2 objectAtIndex:indexPath.row];
cell.NameLabel.text = item.detailN
cell.priceLabel.text = [NSString stringWithFormat:@"¥%@",item.detailPrice];
cell.priceLabel.textColor = [UIColor redColor];
//cell.volLabel.text = item.detailS
[cell.imageView setImageWithURL:[NSURL URLWithString:item.detailPicture60] placeholderImage:[UIImage imageNamed:@"Placeholder"]];
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
ShangPinDetailViewController *detailViewController = [[ShangPinDetailViewController alloc]init];
if (mTableView.tag == 100)
NSLog(@"111");
detailViewController.mArray = dataA
detailViewController.mRow = indexPath.
if (mTableView.tag == 101)
NSLog(@"222");
detailViewController.mArray = dataArray1;
detailViewController.mRow = indexPath.
if (mTableView.tag == 102)
NSLog(@"333");
detailViewController.mArray = dataArray2;
detailViewController.mRow = indexPath.
detailViewController.modalTransitionStyle = UIModalTransitionStyleFlipH
[self.navigationController pushViewController:detailViewController animated:YES];
- (void)viewDidUnload
[super viewDidUnload];
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
return (interfaceOrientation == UIInterfaceOrientationPortrait);
登录后方可回复
问题一:先加入购物车,然后在购物车里面看到之前加入的商品,然后在购物车中有个结算按钮,单击按钮进行支付
问题二:代码如下:
#import "FirstViewController.h"
#import "ShangPinListCell.h"
#import "ShangPinDetailViewController.h"
#import "UIImageView+WebCache.h"
#import "UIImageView+WebCache.h"
#import "FirstViewItem.h"
#import "ShangPinCategoryItem.h"
@implementation FirstViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
UITabBarItem *barItem = [[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"blue-home-icon.png"] tag:100];
self.tabBarItem = barI
[barItem release];
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
-(void)createNav
UIBarButtonItem *itemLeft = [[UIBarButtonItem alloc]initWithTitle:@"切换区域" style:UIBarButtonItemStylePlain target:self action:@selector(ClickedButtonLeft:)];
self.navigationItem.leftBarButtonItem = itemL
[itemLeft release];
UIButton *buttonRight = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"playback_reload.png"]];
imageView.frame = CGRectMake(7, 5, 15, 15);
buttonRight.frame = CGRectMake(0, 0, 30,25);
[buttonRight addTarget:self action:@selector(ClickedButtonRight:) forControlEvents:UIControlEventTouchUpInside];
[buttonRight addSubview:imageView];
UIBarButtonItem *buttonRightBar = [[UIBarButtonItem alloc]initWithCustomView:buttonRight];
self.navigationItem.rightBarButtonItem = buttonRightB
- (void)viewDidLoad
[super viewDidLoad];
[self createNav];
dataArray = [[NSMutableArray alloc]init];
dataArray1 = [[NSMutableArray alloc]init];
dataArray2 = [[NSMutableArray alloc]init];
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ChatBackground_00.jpg"]];
imageView.frame = CGRectMake(0, 0, 320, 380);
[self.view addSubview:imageView];
[imageView release];
UISearchBar *searchBar = [[UISearchBar alloc]init];
searchBar.frame = CGRectMake(0, 0, 320, 44);
searchBar.barStyle = UIBarStyleB
searchBar.placeholder = @"搜索商品";
[self.view addSubview:searchBar];
UISearchDisplayController *dis = [[UISearchDisplayController alloc]initWithSearchBar:searchBar contentsController:self];
dis.searchResultsDelegate =
dis.searchResultsDataSource =
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"activated_btn.png"] forBarMetrics:UIBarMetricsDefault];
self.navigationItem.title = @"首页";
areasViewController = [[RootViewController alloc]init];
//创建滚动视图
CGRect frameScrollView = [[UIScreen mainScreen]bounds];
frameScrollView.origin.y +=44;
frameScrollView.size.height -=70+44;
mScrollView = [[UIScrollView alloc]initWithFrame:frameScrollView];
mScrollView.contentSize = CGSizeMake(320*3, frameScrollView.size.height);
mScrollView.showsHorizontalScrollIndicator = NO;
mScrollView.pagingEnabled = YES;
for (int i = 0; i & 3; i++)
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(320*i, 0, 320, 110)];
if (i == 0)
[imageView setImageWithURL:[NSURL URLWithString:@"8a20aafc6_600.jpg"]];
[imageView setImageWithURL:[NSURL URLWithString:@"8a20aaf240d8aa.jpg"]];
[imageView setImageWithURL:[NSURL URLWithString:@"8a20aaf240dc72c.jpg"]];
pageCtrl = [[UIPageControl alloc]initWithFrame:CGRectMake(130+320*i, 0, 60, 20)];
[pageCtrl setNumberOfPages:3];
[mScrollView addSubview:pageCtrl];
CGRect frame = [[UIScreen mainScreen]bounds];
frame.origin.y += 110;
frame.origin.x +=320*i;
frame.size.height = 215;
mTableView = [[UITableView alloc]initWithFrame:frame style:UITableViewStyleGrouped];
mTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleW
mTableView.delegate =
mTableView.dataSource =
mTableView.backgroundColor = [UIColor clearColor];
mTableView.tag = i+100;
[mScrollView addSubview:mTableView];
[mScrollView addSubview:imageView];
[self.view addSubview:mScrollView];
httpRequest = [[QFHttpRequest alloc]init];
httpRequest.delegate =
httpRequest.method = @selector(downloadComplete:);
[httpRequest requestWithUrl:@""];
-(void)downloadComplete:(QFHttpRequest*)request
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:request.downloadData options:NSJSONReadingMutableContainers error:nil];
for (int i= 0; i&3; i++)
UITableView *tempTable = (UITableView *)[mScrollView viewWithTag:i+100];
NSArray *array = [dict objectForKey:@"indexFloorModules"];
NSDictionary *subDict = [array objectAtIndex:2];
NSArray *subArray = [subDict objectForKey:@"specialOffers"];
NSDictionary *subDict1 = [subArray objectAtIndex:0];
strTitle1 = [subDict1 objectForKey:@"name"];
NSArray *productArray = [subDict1 objectForKey:@"products"];
for (NSDictionary *dic in productArray)
ShangPinCategoryItem *item = [[ShangPinCategoryItem alloc]init];
item.detailName = [dic objectForKey:@"name"];
item.detailSize = [dic objectForKey:@"size"];
item.detailPrice = [NSString stringWithFormat:@"¥%@",[dic objectForKey:@"price"]];
item.detailMarketPrice = [NSString stringWithFormat:@"¥%@",[dic objectForKey:@"marketPrice"]];
NSDictionary *dictionary = [dic objectForKey:@"featurePicture"];
item.detailPicture60 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size60"]];
item.detailPicture180 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size180"]];
item.detailPicture360 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size600"]];
[dataArray addObject:item];
NSLog(@"dataArray==%@",dataArray);
NSMutableArray *mArray = [[NSMutableArray alloc]initWithCapacity:0];
NSArray *array = [dict objectForKey:@"indexFloorModules"];
NSDictionary *subDict = [array objectAtIndex:3];
NSArray *subArray = [subDict objectForKey:@"specialOffers"];
for (NSDictionary *subDict1 in subArray)
NSArray *productArray = [subDict1 objectForKey:@"products"];
for (NSDictionary *dic in productArray)
ShangPinCategoryItem *item = [[ShangPinCategoryItem alloc]init];
item.detailName = [dic objectForKey:@"name"];
item.detailSize = [dic objectForKey:@"size"];
item.detailPrice = [NSString stringWithFormat:@"¥%@",[dic objectForKey:@"price"]];
item.detailMarketPrice = [NSString stringWithFormat:@"¥%@",[dic objectForKey:@"marketPrice"]];
NSDictionary *dictionary = [dic objectForKey:@"featurePicture"];
item.detailPicture60 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size60"]];
item.detailPicture180 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size180"]];
item.detailPicture360 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size600"]];
[mArray addObject:item];
[dataArray1 addObject:mArray];
NSLog(@"dataArray1==%@",dataArray1);
NSArray *array = [dict objectForKey:@"indexFloorModules"];
NSDictionary *subDict = [array objectAtIndex:4];
NSArray *subArray = [subDict objectForKey:@"specialOffers"];
NSDictionary *subDict1 = [subArray objectAtIndex:0];
NSArray *productArray = [subDict1 objectForKey:@"products"];
for (NSDictionary *dic in productArray)
ShangPinCategoryItem *item = [[ShangPinCategoryItem alloc]init];
item.detailName = [dic objectForKey:@"name"];
item.detailSize = [dic objectForKey:@"size"];
item.detailPrice = [NSString stringWithFormat:@"%@",[dic objectForKey:@"price"]];
item.detailMarketPrice = [NSString stringWithFormat:@"%@",[dic objectForKey:@"marketPrice"]];
NSDictionary *dictionary = [dic objectForKey:@"featurePicture"];
item.detailPicture60 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size60"]];
item.detailPicture180 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size180"]];
item.detailPicture360 = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"size600"]];
[dataArray2 addObject:item];
NSLog(@"dataArray2==%@",dataArray2);
[tempTable reloadData];
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
CGFloat aWidth = scrollView.frame.size.
NSInteger curPageView = floor(scrollView.contentOffset.x/aWidth);//获得当前页数
[pageCtrl setCurrentPage:curPageView];
-(void)viewWillAppear:(BOOL)animated
UIColor *color = [[UIColor alloc]initWithRed:0 green:0.1 blue:0.1 alpha:0.1];
self.navigationController.navigationBar.tintColor =
-(void)ClickedButtonLeft:(UIBarButtonItem*)button
[self presentViewController:areasViewController animated:YES completion:nil];
-(void)ClickedButtonRight:(UIBarButtonItem*)button
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
if (mTableView.tag == 101)
NSLog(@"第一个tableview");
return [dataArray1 count];
if (mTableView.tag == 100)
NSLog(@"第二个tableview");
return [dataArray count];
NSLog(@"第3个tableview");
return [dataArray2 count];
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
if (tableView.tag == 101)
NSLog(@"第二个tableview的组数");
NSLog(@"其他tableview的组数");
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
return 75;
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
if (mTableView.tag == 100)
NSLog(@"1");
return strTitle1;
if(mTableView.tag == 101)
NSLog(@"2");
if (section==0)
stringTitle = @"百事系列";
if (section==1)
stringTitle = @"可口系列饮料";
if (section==2)
stringTitle = @"矿泉水";
return stringT
NSLog(@"3");
stringTitle = @"零食天堂";
return stringT
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *cellName = @"ID";
ShangPinListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
if (cell == nil)
cell = [[[NSBundle mainBundle]loadNibNamed:@"ShangPinCell" owner:self options:nil]lastObject];
cell.selectionStyle = UITableViewCellSelectionStyleN
if (mTableView.tag == 100)
NSLog(@"++++++++++++++++");
ShangPinCategoryItem *item = [dataArray objectAtIndex:indexPath.row];
cell.NameLabel.text = item.detailN
cell.priceLabel.text = [NSString stringWithFormat:@"¥%@",item.detailPrice];
cell.priceLabel.textColor = [UIColor redColor];
//cell.volLabel.text = item.detailS
[cell.imageView setImageWithURL:[NSURL URLWithString:item.detailPicture60] placeholderImage:[UIImage imageNamed:@"Placeholder"]];
if (mTableView.tag == 101)
NSLog(@"[][][][][][]");
ShangPinCategoryItem *item = [[dataArray1 objectAtIndex:indexPath.section]objectAtIndex:indexPath.row];
cell.NameLabel.text = item.detailN
cell.priceLabel.text = [NSString stringWithFormat:@"¥%@",item.detailPrice];
cell.priceLabel.textColor = [UIColor redColor];
//cell.volLabel.text = item.detailS
[cell.imageView setImageWithURL:[NSURL URLWithString:item.detailPicture60] placeholderImage:[UIImage imageNamed:@"Placeholder"]];
if(mTableView.tag == 102)
NSLog(@"hello");
ShangPinCategoryItem *item = [dataArray2 objectAtIndex:indexPath.row];
cell.NameLabel.text = item.detailN
cell.priceLabel.text = [NSString stringWithFormat:@"¥%@",item.detailPrice];
cell.priceLabel.textColor = [UIColor redColor];
//cell.volLabel.text = item.detailS
[cell.imageView setImageWithURL:[NSURL URLWithString:item.detailPicture60] placeholderImage:[UIImage imageNamed:@"Placeholder"]];
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
ShangPinDetailViewController *detailViewController = [[ShangPinDetailViewController alloc]init];
if (mTableView.tag == 100)
NSLog(@"111");
detailViewController.mArray = dataA
detailViewController.mRow = indexPath.
if (mTableView.tag == 101)
NSLog(@"222");
detailViewController.mArray = dataArray1;
detailViewController.mRow = indexPath.
if (mTableView.tag == 102)
NSLog(@"333");
detailViewController.mArray = dataArray2;
detailViewController.mRow = indexPath.
detailViewController.modalTransitionStyle = UIModalTransitionStyleFlipH
[self.navigationController pushViewController:detailViewController animated:YES];
- (void)viewDidUnload
[super viewDidUnload];
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
return (interfaceOrientation == UIInterfaceOrientationPortrait);
登录后方可回复
1.很多方法。比如定义一个全局变量NSArray,把商品放进去。为了防止数据丢失,还可以写到plist或者sqlite里面。
2. mTableView指向了同一个变量。应该把定义变量放在for循环里面。或者在外面定义三个变量
登录后方可回复
另外,贴代码只需要贴关键部位的。。。这么长没法看。。
登录后方可回复
登录后方可回答
耗时 0.0849 秒

我要回帖

更多关于 dota屠夫钩子 的文章

 

随机推荐