2012-09-26 44 views
0

我在这里有一个问题。所以我想要做的是在分页的UIScrollView中添加几个TableView。我有一个名为CustomView的类,它是UITableView类。它作为一个表视图单独工作。所以它没有问题。于是,我就加他们这样在.h文件中:在UIScrollView UITableView

#import <UIKit/UIKit.h> 

    @interface PagedScrollViewController : UIViewController { 

    UIScrollView *scrollView; 

} 

@property (nonatomic, retain) IBOutlet UIScrollView *scrollView; 

@end 

和.M:

@synthesize scrollView; 

     - (void)viewDidLoad 
     { 
      [super viewDidLoad]; 
      int numberOfPages = 3; 
      for (int i = 0; i < numberOfPages; i++) { 
       CGRect frame = CGRectMake(self.scrollView.frame.size.width * i, 
             0.0, 
             self.scrollView.frame.size.width, 
             self.scrollView.frame.size.height); 
      CustomView *customView = [[CustomView alloc] initWithStyle:UITableViewStyleGrouped]; 
      customView.view.frame = frame; 
      [self.scrollView addSubview:customView.view]; 
     } 

     self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * numberOfPages, 
               self.scrollView.frame.size.height - self.navigationController.navigationBar.frame.size.height); 

    } 

它显示只是没有任何细胞的空表视图。我究竟做错了什么?顺便说一句,它在我开始使用故事板之前完美运行。 谢谢,提前。

更重要的是,在iOS 5我在控制台得到一个SIGABRT: 终止应用程序由于未捕获的异常 'NSInvalidArgumentException',原因是: ' - [CALayer的numberOfSectionsInTableView:]:无法识别的选择发送到实例0x6a2fc00'

回答

0

如果您未实施,我认为您必须实施要求UITableViewDataSource方法。

像:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
+0

是啊,我没在CustomView类 – Noobass

1

试试这个

[customView.tableView reloadData] 
+0

我应该尝试的周期里面? – Noobass