अद्यतन नहीं है मूल प्रश्न क्षमा करें, लेकिन यह मुझे थोड़ी देर के लिए बग करता है।UILabel
मैं एक विवरण एक uitable से देख सकते हैं और गतिशील रूप से अपने लेबल सेट करने का प्रयास बनाने के लिए, लेकिन वे अद्यतन करने नहीं हैं:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
myObject *tmpObj = [[myObject objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
myViewController *tmpVC = [[myViewController alloc] initWithNibName:@"NIBfile" bundle:nil];
[tmpVC.myLabel setText:tmpObj.myTitle]; // The debugger shows the text: myTitle = "myText"
NSLog(@"%@", tmpVC.myLabel); // NSLog SHOWS NULL
[self.navigationController pushViewController:tmpVC animated:YES];
[tmpObj release];
}
इंटरफ़ेस बिल्डर में कनेक्शन स्थापित कर रहे हैं। फ़ाइल स्वामी के लिए कनेक्शन टैब दिखाता है
'myLabel' - 'Label (myLabel)'
कोई विचार क्यों मूल्य नहीं आ रहा है?
कुछ और टिप्पणियों:
- मैं भी एक IBAction कनेक्ट किया है। जब मैं कनेक्ट बटन पर क्लिक करता हूं तो यह विधि ठीक से कॉल की जाती है।
- मुझे अपने एनएसएलओजी-स्टेटमेंट में कुछ पॉइंटर्स मिल गए हैं, चाहे बेहतर tmpVC.myLabel.text, का उपयोग न करें, लेकिन यह भी प्रयास करने की कोशिश कर रहा है।
- myLabel को इंटरफ़ेस में आईबीओलेट UILabel * myLabel के रूप में घोषित किया गया है। संपत्ति को nonatomic, के रूप में परिभाषित किया गया है।
प्रकाश है:
थोड़ा के लिए इसके साथ चारों ओर खेलने के बाद अधिक मैं लेबल अद्यतित ऊपर pushViewController बयान ले जाया गया। इसने लेबल अपडेट को हल किया।
कार्य कोड इस तरह दिखता है:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
myObject *tmpObj = [[myObject objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
myViewController *tmpVC = [[myViewController alloc] initWithNibName:@"NIBfile" bundle:nil];
[self.navigationController pushViewController:tmpVC animated:YES];
[tmpVC.myLabel setText:tmpObj.myTitle]; // The debugger shows the text: myTitle = "myText"
NSLog(@"%@", tmpVC.myLabel); // NSLog SHOWS NULL
[tmpObj release];
}
लेकिन मुझे समझ नहीं आता क्यों मैं अपने ViewController पुश करने के लिए की जरूरत है ???
आप अन्य अपने कोड में कहीं भी इसे जारी करते dealloc से? – Codezy