像app store一样的xcode水平表

时间:2013-05-14 09:30:55

标签: xcode tableview horizontal-scrolling

我试图在表格单元格中创建一个表格来呈现类似于应用程序商店的水平表格单元格幻灯片。

如果您进入应用程序商店并单击特色产品选项卡,您将看到我的意思。

嵌套的水平幻灯片表。

我已经下载了一个可以从互联网上运行得很好但是它似乎使用了笔尖。我希望使用故事板功能创建一个。我的理由是,我觉得它很容易使用,特别是在做segues等时

到目前为止,我已经完成了一个完整但我似乎无法调整单元格以使其正确适合(即,单元格宽度是旋转表格的高度)

这是我从下载源中复制的一些代码

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

   if (cell == nil) {

       CGAffineTransform rotateTable = CGAffineTransformMakeRotation(-M_PI_2);
       tableViewCell.horizontalTableView.transform = rotateTable;
       tableViewCell.horizontalTableView.frame = CGRectMake(0, 0, tableViewCell.horizontalTableView.frame.size.width, tableViewCell.horizontalTableView.frame.size.height);

      tableViewCell.contentArray = [arrays objectAtIndex:indexPath.section];

      tableViewCell.horizontalTableView.allowsSelection = YES;
      //cell = tableViewCell.horizontalTableView;

     }

    return cell;
} 

表格单元格

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   static NSString *CellIdentifier = @"Cell";
   UITableViewCell *cell = [self.horizontalTableView dequeueReusableCellWithIdentifier:CellIdentifier];
   if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
   }

   for (UIImageView *view in cell.subviews) {
       [view removeFromSuperview];
   }

   CGAffineTransform rotateTable = CGAffineTransformMakeRotation(-M_PI_2);
   horizontalTableView.transform = rotateTable;
   horizontalTableView.frame = CGRectMake(0, 0, horizontalTableView.frame.size.width, horizontalTableView.frame.size.height);

   tableViewCell.contentArray = [arrays objectAtIndex:indexPath.section];

   horizontalTableView.allowsSelection = YES;

   UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
   imageView.image = [contentArray objectAtIndex:indexPath.row]];
   imageView.contentMode = UIViewContentModeCenter;

   CGAffineTransform rotateImage = CGAffineTransformMakeRotation(M_PI_2);
   imageView.transform = rotateImage;

   [cell addSubview:imageView];

   return cell;
}

请允许我解释所发生的问题: - cell == nil不起作用,因为单元格似乎不是零; - cell = tableViewCell.horizo​​ntalTableView被注释掉,因为我总是得到UITableView dataSource必须从tableView返回一个单元格:cellForRowAtIndexPath错误 - 单元格旋转似乎工作,因为我在表格单元格部分,但这似乎是问题所在,因为我无法调整大小

如果有人可以帮我处理我的代码,或者将我指向一个有工作故事板嵌套水平表的网站,我们将不胜感激。

(请记住,我还没有被称为应用程序开发方面的专家,但我正试图将其拉下来)

0 个答案:

没有答案
相关问题