UITableView
Webサービスからのデータを読み込もうとしています。すべてが正常に機能しています。UITableView
しかし、デリゲートメソッドを使用してレコードが表示されているときはいつでも、以下の-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
ような例外が発生します-
これが私のコードです-
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell; //= [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Reuse_Cell"];
UILabel *label = nil;
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.selectedBackgroundView = [[UIView alloc]init];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
label = [[UILabel alloc]initWithFrame:CGRectZero];
[label setLineBreakMode:UILineBreakModeWordWrap];
[label setNumberOfLines:1];
[label setFont:[UIFont fontWithName:@"Trebuchet MS" size:18]];
[label setTag:1];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];
[[cell contentView] addSubview:label];
}
if (!label)
label = (UILabel *)[cell viewWithTag:1];
[label setText:[[webserviceRecords objectAtIndex:indexPath.row] objectForKey:@"catName"]];
[label setFrame:CGRectMake(10.0, 5.0, 225.0, 35.0)];
cell.selectedBackgroundView.backgroundColor = RGBACOLOR(151.0, 191.0, 69.0, 1.0);
cell.layer.borderWidth = 2.0f;
cell.layer.borderColor = RGBCOLOR(214, 218, 1).CGColor;
return cell;
}
マイアレイレコード-
カスタムinit
メソッド
- (id)initwithInteger:(NSInteger )integer
{
self = [super init];
if (self) {
startingpage = integer;
webserviceRecords = [[NSMutableArray alloc]init];
}
return self;
}
NumberofRowsInSection
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"Row count - %d", [webserviceRecords count]);
return [webserviceRecords count];
}