2013-10-19 5 views
5

में लेबल प्रदर्शित करता है मेरे पास एक टेबल व्यू है और मैंने सभी विषम सेल ऊंचाई = 0 सेट की है, अजीब सेल में मेरे कुछ लेबल थे। जब यह तालिका दृश्य दिखाता है, तो अजीब सेल में लेबल भी सेल में दिखाई देता है। क्या लेबल गायब होने का कोई तरीका है? यह समस्या आईओएस 6 पी/एस: आईओएस 7 में हुई: यह सही काम करता है। मेरे पास पहले से ही विधि थी: [tableView startUpdates]; [tableView endUpdates];heightForRowAtIndexPath = 0 लेकिन यह अभी भी अपनी पंक्ति

धन्यवाद।

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    // show odd row 
    if (selectedRow == indexPath.row) return 78; 

    // hide odd row and show even row 
    if (indexPath.row %2 ==0){ 
     return 88;} 
    else{ 
     return 0;} 
} 

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


    if (indexPath.row%2 == 0){ 


     //user click on even row -> display the next row 
     selectedRow = indexPath.row+1; 

     [tableView beginUpdates]; 

     [tableView endUpdates]; 

    } 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    int index = indexPath.row/2; 

    if (indexPath.row %2 ==0){ 

     static NSString *CellIdentifier = @"PhraseViewCell"; 

     PhraseCellVietnamese *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

     NSString *phrase = [[phrases objectAtIndex:index] objectForKey:@"vietnamese"]; 

     NSNumber *checkFavorite = [[phrases objectAtIndex:index] objectForKey:@"favorite"]; 

     NSNumber *phraseId =[[phrases objectAtIndex:index] objectForKey:@"_id"]; 

     [cell SetInfo:phrase :checkFavorite.intValue :phraseId.intValue]; 

     return cell; 

    } 
    else{ 

     static NSString *CellIdentifier = @"PinyinViewCell"; 

     PinYinViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

     NSString *pinyin = [[phrases objectAtIndex:index] objectForKey:@"pinyin"]; 

     NSString *chinese = [[phrases objectAtIndex:index] objectForKey:@"chinese"]; 

     NSString *voice = [[phrases objectAtIndex:index] objectForKey:@"voice"]; 

     [cell setInfo:pinyin :chinese :voice]; 

     return cell; 
    } 
} 
+0

क्या होगा यदि आप सेल की सामग्री के लिए हाँ में क्लिपिंग उप-दृश्य सेट करते हैं? – Zen

+0

इसे कैसे सेट करें? क्षमा करें क्योंकि मैं नौसिखिया – tommy

+1

'[cell.contentView setClipsToBounds: YES];' – Zen

उत्तर

20

[सेल सेटक्लिप्स टूबाउंड्स: हाँ]; cellForRowAtIndexPath

मेरे लिए काम किया। आशा है कि आपको अपना समाधान मिलेगा।

+1

मेरे जीवन को बचाया। :) – yuhua

+0

मेरे साथ ही। चेयर – Allamaprabhu

+0

अच्छा समाधान, Thx! –

3

उपयोगकर्ता 2799736 उत्तर पढ़ने के बाद मैंने क्लिप सबव्यू को .xib फ़ाइल में YES में बदल दिया। मेरे लिए काम किया।

+0

अच्छा समाधान, Thx! –

संबंधित मुद्दे