2014-11-05 5 views
7

मेरे पास प्रति अनुभाग 4 अनुभाग और 1-2 तालिका दृश्य कक्षों के साथ एक तालिका दृश्य है। पहले सेल में एक एक्सेसरी व्यू के रूप में एक यूज़विच है और ऐप के कलर थीम को नियंत्रित करता है, दिन मोड और रात मोड के बीच स्विचिंग करता है। स्विच स्विच होने के बाद एक समारोह को बुलाया जाता है, नेविगेशन बार और पृष्ठभूमि रंग के रंग बदलते हैं। उस फ़ंक्शन में मैंने लाइन कोतालिका दृश्य खंडों को फिर से लोड करें

[self.tableview reloadData]; 

को नए रंगों के साथ तालिका को अपडेट करने के लिए भी लाइन डाली है। यह ठीक काम करता है, लेकिन यह करने के लिए कोई एनीमेशन theres, तो मैं बजाय

[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)] withRowAnimation:UITableViewRowAnimationFade]; 

जब कि लाइन स्विच अटक जाती है और एप्लिकेशन को फ्रीज़ प्रयोग किया जाता है इस का इस्तेमाल किया। यह प्रति कहने में दुर्घटनाग्रस्त नहीं होता है, यानी कोई क्रैश लॉग नहीं है, यह बस जम जाता है और यूज़विच मध्य एनीमेशन बंद कर देता है।

मैंने देखा कि मैं उन अनुभागों को फिर से लोड कर सकता हूं जिनमें कोशिकाएं नहीं हैं जिनमें सहायक दृश्य शामिल हैं और यह फीका एनीमेशन के साथ पूरी तरह से काम करता है। अर्थात। यह

[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationFade]; 

क्योंकि तीसरे अनुभाग में सहायक दृश्यों वाले कोई भी कक्ष नहीं है। लेकिन कोई भी अनुभाग जिसमें एक सेल है जिसमें एक्सेसरी व्यू (यानी अनुभाग 0 और 2) शामिल है, यदि मैं इसे ऐप फ्रीज करने और पुनः लोड करने का प्रयास करता हूं।

कोई विचार यह क्यों हो रहा है? नीचे मेरी cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *cellIdentifier; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier]; 

if (indexPath.section == 0) { 

    cell.textLabel.text = [section0 objectAtIndex:indexPath.row]; 
    cell.accessoryType = UITableViewCellAccessoryNone; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 

    if (indexPath.row == 0) { 

     cell.accessoryView = colorSchemeSwitch; 
    } 

    else if (indexPath.row == 1) { 

     cell.accessoryView = autoLockSwitch; 
    } 
} 

else if (indexPath.section == 1) { 

    cell.textLabel.text = [section1 objectAtIndex:indexPath.row]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
} 

else if (indexPath.section == 2) { 

    cell.textLabel.text = [section2 objectAtIndex:indexPath.row]; 
    cell.accessoryType = UITableViewCellAccessoryNone; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%i \t", (int)app.fontSize]; 
    fontSizeSlider.value = app.fontSize; 
    cell.accessoryView = fontSizeSlider; 
} 

else if (indexPath.section == 3) { 

    cell.textLabel.text = [section3 objectAtIndex:indexPath.row]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    cell.detailTextLabel.text = app.color; 
} 

cell.backgroundColor = app.cellBackgroundColor; 
cell.textLabel.textColor = app.textColor; 
UIView *backgroundColorView = [[UIView alloc] init]; 
backgroundColorView.backgroundColor = app.cellSelectedColor; 
[cell setSelectedBackgroundView:backgroundColorView]; 

return cell; 
} 
+0

कृपया अपने प्रश्न में क्रैश लॉग संलग्न करें। –

+0

यह वास्तव में विचित्र है, कोई क्रैश लॉग नहीं है, ऐप फ्रीज करता है, यह क्रैश नहीं होता है। स्विच बीच में फंस जाता है और ऐप अनुत्तरदायी हो जाता है। कोई क्रैश लॉग –

+0

कोई सुझाव नहीं? –

उत्तर

7

मुझे UITableViewCell में UISwitch में एक ही समस्या थी। मैं वर्गों को फिर से लोड करने से पहले [self.tableview reloadData] फोन करके समस्या का समाधान:

NSIndexSet *sections = [[NSIndexSet alloc] initWithIndex:2]; 
[self.tableView reloadData]; 
[self.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationFade]; 

एक ही समस्या होता है अगर आप कॉल:

[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationFade] 

पहले डेटा को पुन: लोड के बिना।

+0

आप एक किंवदंती हैं! यह पूरी तरह से काम किया।विश्वास नहीं कर सकता कि यह आसान –

+13

था यदि हम रीलोड टेबल को कॉल कर रहे हैं तो एनीमेशन के लिए पुनः लोडिंग अनुभाग की आवश्यकता क्यों है? (एच) – dip

+3

मैं @ डीआईपी से सहमत हूं, या तो "रीलोडडाटा" या "रीलोडक्शन" कहा जाना चाहिए, लेकिन दोनों नहीं। इसके साथ ही, मुझे यादृच्छिक रूप से "beUpdates" और "endUpdates" के बीच "रीलोडक्शन" का उपयोग करके SIGABRT क्रैश मिलता है। मैं अभी भी यह पता लगाने की कोशिश कर रहा हूं कि क्यों ... –

2

आप अनुमान लगा तो आपको एक त्रुटि एक वर्ग में पंक्तियों की एक मौजूदा संख्या कहा गया है कि एक अद्यतन करने से पहले कुछ मूल्य के बराबर होना चाहिए हो रही है नहीं जोड़ा है एक दुर्घटना लॉग लेकिन im है। यदि ऐसा है, तो क्या आपने तालिका को पुनः लोड करने से पहले [self.tableview beginUpdates] का उपयोग किया था और [self.tableview endUpdates] पुनः लोड करने के बाद?

+0

अजीब बात यही है, वहाँ कोई क्रैश लॉग, एप्लिकेशन फ्रीज़ है, यह –

+0

क्रैश नहीं होता मैं शुरू करते हैं और अद्यतन अंत लेकिन कोई परिवर्तन नहीं –

+0

कोशिश इसे यहाँ dispatch_async जोड़ने (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0 के साथ कोड sandwiching की कोशिश की है),^{// यहां कोड डालें}); –

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