所以我有幾個視圖控制器在IB中設置。一個具有大約6個單元格的TableView(以編程方式填充)。然後再添加6個視圖控制器(每個單元格一個)。以編程方式切換視圖
我想要讓這個在我
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
我可以使視圖切換到哪個觀點是相對於單擊單元格。
所以,如果他們點擊cell1,它會去view1,如果他們點擊cell2,它會去view2。
這是我如何初始化我的表只是順便說一句,它工作正常。
//tableview datasource delegate methods
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return showArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if(cell == nil){
cell = [[CustomCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.showLabel.text = [showArray objectAtIndex:indexPath.row];
cell.image.image = [UIImage imageNamed:[imageArray objectAtIndex:indexPath.row]];
cell.seasonLabel.text = [seasonArray objectAtIndex:indexPath.row];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 106;
}
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation: (UITableViewRowAnimation)animation{
NSIndexPath *newCellPath = [NSIndexPath indexPathForRow:showArray.count
inSection:0];
[self.theatreView insertRowsAtIndexPaths:@[newCellPath]
withRowAnimation:UITableViewRowAnimationFade];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
你怎麼讓你的應用程序結構化。它坐在導航控制器中嗎? – Bergasms
@Bergasms不,它有一個視圖控制器是主菜單,它只是從控制器到控制器使用UIButtons – tyler53