2013-06-25 39 views
0

我正在使用UITableViewJson解析。UITableView永遠不會調用didSelectRowAtIndexPath

-(void) connectionDidFinishLoading :(NSURLConnection *) connection{ 

    self.resultTable.delegate = self; 

    self.resultTable.dataSource = self; } 

我解析數據並設置UITableView'sdelegatedatasource自我。

當我編譯該程序時,我用jSON解析的數據沒有任何問題。

的主要問題是:當我嘗試挖掘到行的表,調試器從不來

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

我試過很多東西(包括Segue公司等。)但是我不能選擇的任何細胞的行與我的手指輕敲。它真的感覺我喜歡攻絲文字...

任何人都知道這個問題?

問候......

CNC中

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    _userSettings = [NSUserDefaults standardUserDefaults]; 

    static NSString *CellIdentifier [email protected]"CellID"; 


    ResultNearbyList *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    [cell.profilePictureIndicator startAnimating]; 

     if (cell == nil) { 
      cell = [[ResultNearbyList alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
     } 

     cell.userProfilePicture.profileID = [userFBIDArray objectAtIndex:indexPath.row]; 

    self.userDOBStr = [userDOB objectAtIndex:indexPath.row]; 

    self.userGenderStr = [userGender objectAtIndex:indexPath.row]; 

     [cell.profilePictureIndicator stopAnimating]; 

     [_listNearbyView stopAnimating]; 


     cell.userNickName.text = [userNickNameArray objectAtIndex:indexPath.row]; 

     NSString *fullName = [userFullNameArray objectAtIndex:indexPath.row]; 


     NSString* fullNameUTF8 = [NSString stringWithUTF8String:[fullName cStringUsingEncoding:NSUTF8StringEncoding]]; 


     //NSString *fullNameUTF8 = [NSString stringWithCString:[fullName cStringUsingEncoding:NSISOLatin1StringEncoding] encoding:NSUTF8StringEncoding]; 


     cell.userFullName.text = fullNameUTF8; 

     NSString *userCityCountry = [userCountryArray objectAtIndex:indexPath.row]; 

     userCityCountry = [userCityCountry stringByAppendingString:@"/"]; 

     userCityCountry = [userCityCountry stringByAppendingString:[userCityArray objectAtIndex:indexPath.row]]; 

     cell.userCityCountry.text = userCityCountry; 

     NSString *userDestination = [userDistanceArray objectAtIndex:indexPath.row]; 

     NSRange range = [userDestination rangeOfString:@"."]; 

     NSString *substring = (range.location != NSNotFound) ? [userDestination substringToIndex:range.location] : nil; 

     substring = [substring stringByAppendingString:@" km"]; 

     if([substring intValue] == 0) 
     { 
      substring = (range.location != NSNotFound) ? [userDestination substringFromIndex:range.location] : nil; 

      substring = [substring substringWithRange:NSMakeRange(0, 4)]; 

      substring = [substring stringByAppendingString:@" m"]; 
     } 



     cell.userDistance.text = substring; 

     return cell; 

} 

屏幕截圖:1

+1

你可以顯示你的代碼爲cellForRowAtIndexPath? – micantox

+0

是您長按時突出顯示的單元格嗎? – Wain

+0

@micantox,我編輯過。 Wain,不是。它不高的燈光... –

回答

0

轉到你的故事板,選擇UITable和檢查,看看是否選擇設置爲「單選擇」。還要注意勾選「觸摸顯示選擇」

enter image description here

+0

它被設置爲單選,並檢查顯示選擇在觸摸:( –

+0

我嘗試了一切,除了處理connectionDidFinishLoading和推另一個viewController之後的數組中的所有數據。我認爲使用GDC和TableView使問題 有沒有好的例子來處理NSURLConnection和Tableview在同一個UIView中? –

0

我發現我錯了。我缺少的部分是,我只是添加Objective-C類文件作爲UIViewController創建單元格原型視圖。比我更改了UIViewController - > UITableViewCell。但手動更改爲類類型,沒有添加以下情況:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 
{ 
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) { 
     // Initialization code 
    } 
    return self; 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated 
{ 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 

當我設置這些實例以我的UITableViewCell類實現文件,這個問題已經修復:)

謝謝你的幫助。 ..

相關問題