Ios UITableView未显示数据,用作iCarousel视图
(制作一个iPad应用程序)在我的Ios UITableView未显示数据,用作iCarousel视图,ios,uitableview,icarousel,Ios,Uitableview,Icarousel,(制作一个iPad应用程序)在我的iCarousel中有两个UITableView当我滑动到下一个iCarousel视图时,我在UITableView中什么也没有得到。当我将numberOfRowsInsection保持为常量时,就没有问题了。但是,当我试图更改UITableView的数据源时,我要么得到NSRangeException,要么在UITableView中什么都没有。下面是我所做的代码。 请帮忙。我被困在这里了 #pragma mark-Table View Methods - (
iCarousel
中有两个UITableView
当我滑动到下一个iCarousel
视图时,我在UITableView
中什么也没有得到。当我将numberOfRowsInsection
保持为常量时,就没有问题了。但是,当我试图更改UITableView
的数据源时,我要么得到NSRangeException
,要么在UITableView
中什么都没有。下面是我所做的代码。
请帮忙。我被困在这里了
#pragma mark-Table View Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSInteger carouselIndex = [self.carousel indexOfItemViewOrSubview:tableView];
static NSString *CellIdentifier = @"cell";
NSArray *array= [[NSBundle mainBundle] loadNibNamed:@"toursViewTableCell" owner:self options:nil];
toursViewTableCell *cell = (toursViewTableCell*) [array objectAtIndex:0];
switch (carouselIndex) {
case 0:
if (tableView.tag==111) {
if (cell==nil) {
cell= [[toursViewTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//setting dataSource
dateArrayInTableCellOne=[[NSMutableArray alloc] initWithObjects:@"2014-05-08",@"2014-05-09",@"2014-05-11",@"2014-05-13",@"2014-05-14", nil];
cityArrayInTableCellOne=[[NSMutableArray alloc] initWithObjects:@"Santa Cruz",@"Redding",@"Portland",@"Boise",@"Salt Lake City", nil];
stateArrayInTableCellOne=[[NSMutableArray alloc] initWithObjects:@"CA",@"CA",@"OR",@"ID",@"UT" ,nil];
venueArrayInTableCellOne=[[NSMutableArray alloc] initWithObjects:@"Catalyst Club",@"Cascade Theater",@"Alladin Thearter",@"Knitting Factory",@"The Depot", nil];
//setting Cell
}else if (tableView.tag==222){
//setting dataSource for second tableView
dateArrayInTableCellTwo=[[NSMutableArray alloc] initWithObjects:@"2014-03-04",@"2014-03-05",@"2014-03-07",@"2014-03-08",@"2014-03-11", nil];
cityArrayInTableCellTwo=[[NSMutableArray alloc] initWithObjects:@"Richmond",@"Newport News",@"Charleston",@"Louisville",@"Des Moines", nil];
stateArrayInTableCellTwo=[[NSMutableArray alloc] initWithObjects:@"VA",@"VA",@"WV",@"KY",@"IA",nil];
venueArrayInTableCellTwo=[[NSMutableArray alloc] initWithObjects:@"Carpenter Center",@"Christopher Newport Univ.",@"Clay Center for the Arts & Sciences",@"Palace Theatre",@"Civic Center of Greater Des Moines", nil];
//Setting Cell
}
break;
//Carousel Index Changed
case 1:
if (tableView.tag==111) {
//I am not getting anything here,If i reload tableView . If i dont reload tableView I am getting NSRangeException.
//Changing dataSource
newDateArrayInTableCellOne=[[NSMutableArray alloc] initWithObjects:@"2014-01-16",@"2014-01-28",@"2014-01-29", nil];
newCityArrayInTableCellOne=[[NSMutableArray alloc] initWithObjects:@"Santa Barbara",@"New York City", nil];
newStateArrayInTableCellOne=[[NSMutableArray alloc] initWithObjects:@"CA",@"NY",@"NY", nil];
newVenueArrayInYableCellOne=[[NSMutableArray alloc] initWithObjects:@"The Lobero Theatre",@"City Winery",@"City Winery", nil];
//setting Cell For Carousel Index One
}else if (tableView.tag==222){
//Setting TabeViewCell For Carousel Index One
}
break;
这是我要做的截图。您的代码有点凌乱,哪一行有异常?为什么要调用[tableView numberofrowsin节:newdatearrayintalecellone.count]代码>没有得到结果?@Justafinger我编辑并删除了这些乱七八糟的东西..请看一看我很抱歉,但我相信我们遗漏了一些东西。显示内容中的任何内容都不会导致nsrange异常。当您说将numberOfRowsInsection
保持为常量时,您指的是返回5
。你总是在每个部分有5行吗?你的照片显示4。很多东西都没有真正的意义。@Justafinger我应该在哪里调用[TableView reloadData]
在更改数据源(无论您想在哪里,但不在TableView数据源方法中)之后。