私はiPhone開発に比較的新しいので、スクロールビューにuitableviewを追加しようとしましたが、Sigabartエラーが表示されてしまい、プログラムに追加してuitableviewdelegateとuitableviewデータソースを追加し、 'noOfRowsInSection'メソッドを追加すると、delgateメソッドは呼び出されません。スクロールビューでテーブルビューを追加する
@interface Class : UIViewController<UITableViewDelegate,UITableViewDataSource> {
UITableView *table;
UIScrollView *scrView;
NSArray *array;
}
@property (nonatomic, retain) IBOutlet UIScrollView *scrView;
@end
here is my implementation
- (void)viewDidload
{
array = [[NSArray alloc]initWithObjects:@"harsha",@"theja",@"pandu", nil];
[super viewDidUnload];
table = [[UITableView alloc]initWithFrame:CGRectMake(0, 260, 360, 220)];
[self.view addSubview:table];
table.delegate = self ;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];
return cell;
}
@end
私はインターフェイスビルダーしかしスクロールビューを追加することですが、私はmatically TABLビューが画面に表示されるテーブルビューPROGRAをしていますが、方法は、あなたがして、あなたのコードを配置している
コードとデリゲートメソッドを表示してください:)あなたはinterfacebuilderで接続しましたか? あなたのコンソールがsigbartで表示するエラーは何ですか? –
これには、問題のコードなしではほとんどデバッグが不可能な原因が多数あります。 – mydogisbox
サイドノートでは、UITableViewはUIScrollViewのサブクラスです。したがって、標準的な垂直スクロールだけが必要な場合は、単にUITableViewを使用してください。 – cobbal