私は本当に奇妙な問題を抱えています。
私のtableViewには、すべてのデリゲートとデータソースが設定されています。
すべて順調。
ただし、行をクリックしてもアクティブになりません。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
カスタムセルを使用しました。
クリックしてクリックしてクリックしてクリックしてから、時々それが通過します。
何が原因なのだろうか?customCell がタッチ イベントまたは何かを「吸収」しているように見えますか?
それが理由でしょうか?もしそうなら、customCell を実装し、tableView にタッチアップ イベントを処理させたい場合、どうすればよいでしょうか?
追加の症状:
カスタムセルから有効なユーザー操作を削除すると、問題はキャッチで解決されます。
ただし、ボタンをクリックすると、何らかの理由で customCell 内のすべてのラベル テキストが消去されます。
カスタム Cell の実装は次のとおりです。
- (BGUIBusinessCellForDisplay *) initWithBiz: (Business *) biz
{
if (self.biz == nil) //First time set up
{
self = [super init]; //If use dequeueReusableCellWithIdentifier then I shouldn't change the address self points to right
NSString * className = NSStringFromClass([self class]);
//PO (className);
[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil];
self.frame =self.view.frame;
[self addSubview:self.view]; //What is this for? self.view is of type BGCRBusinessForDisplay2. That view should be self, not one of it's subview Things don't work without it though
}
if (biz==nil)
{
return self;
}
_biz = biz;
self.prominentLabel.text = [NSString stringWithFormat:@"Isi: %@", biz.isiString];
self.Title.text = biz.Title; //Let's set this one thing first
self.Address.text=biz.ShortenedAddress;
//if([self.distance isNotEmpty]){
self.DistanceLabel.text=[NSString stringWithFormat:@"%dm",[biz.Distance intValue]];
self.PinNumber.text =biz.StringPinLineAndNumber;
NSString * URLString=nil;
if(biz.Images.allObjects.count!=0){
//self.boolImage=[NSNumber numberWithBool:true];
Image * image=(biz.Images.allObjects)[0];
URLString = image.URL;
URLString = [NSString stringWithFormat:@"http://54.251.34.144/thumbnailer/Thumbnailer.ashx?imageURL=%@",URLString.UTF8Encode];
//url=[NSURL URLWithString:image.URL];
}else{
float latitude = biz.getCllLocation.coordinate.latitude;
float longitude = biz.getCllLocation.coordinate.longitude;
URLString = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/staticmap?&zoom=16&size=160x160&maptype=roadmap&sensor=true¢er=%f,%f&markers=size:small|color:blue|%f,%f",latitude,longitude,latitude,longitude];
URLString = URLString.UTF8Encode;
}
//Should add code and add loading indicator here
[BGHPTools doBackground:^{
UIImage * imageBiz = [BGMDImageCacherAndDownloader getImageFromURL:URLString];
[BGHPTools doForeGround:^{
self.Image.image=imageBiz;
[self.Image makeRound];
}];
}];
//self.view=self.view;
/*if (self.tableViewCell == Nil)//Instantiate that tableviewCell
{
PO(self.tableViewCell);
}
self.tableViewCell.business = bis;
self.pinLbl.text = bis.StringPinLineAndNumber;
self.lblTitle.text=bis.Title;
//self.pinLbl.text=bis.pinNumber;*/
//}
/*self.name=[dict objectForKey:@"Title"];
self.address=[dict objectForKey:@"Street"];
CLLocation * cll=[[CLLocation alloc]initWithLatitude:[[dict objectForKey:@"Latitude"] doubleValue] longitude:[[dict objectForKey:@"Longitude"] doubleValue]];
self.distance=[NSNumber numberWithDouble:[cll distanceFromLocation:[cachedProperties currentLocation]]];*/
return self;
更新:テキストがなくなった理由はすでにわかっています。私の背景は白であることがわかりました。行が選択されると、テキストが突然白くなります。したがって、選択したスタイルを青に設定することで、それを「固定」することができます。
ただし、基になる tableViewCell が選択されている場合、すべてのラベル テキストを白にするようにコード内で指定している場所がまだわかりません。
結局、選択されるのはセルであり、ラベルではありません。ラベルが白にならなければならないことをどのように知っているのか、私には理解できません。