के बीच पास इंडेक्स संख्या जब मैं अपने UITableView में एक निश्चित सूची आइटम पर क्लिक करता हूं, तो मैं उस आइटम की अनुक्रमणिका को पास करना चाहता हूं जिसे मैंने अगले विस्तृत दृश्य पर क्लिक किया था।UITableView सूची segue
यह मेरा प्रासंगिक कोड अब तक है:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
HomeworkDetails *view = [[HomeworkDetails alloc] init];
int lastIndex = [indexPath indexAtPosition:[indexPath length] - 1];
NSLog(@"%u", lastIndex);
[self performSegueWithIdentifier: @"HomeworkDetailsSegue" sender:self];
view.currentIndex = lastIndex;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
इस बिंदु पर, मैं सफलतापूर्वक अगले ViewController (HomeworkDetails) पर जा सकते हैं, लेकिन जानकारी के माध्यम से पारित नहीं है। मैं view.currentIndex = lastIndex;
कर इसे पूरा करने की कोशिश कर रहा हूं लेकिन यह काम नहीं कर रहा है। मैं यह और कैसे कर सकता हूं? क्षमा करें अगर मुझे कुछ याद आया; मैं आईओएस विकास में एक नौसिखिया हूँ।
:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
HomeworkDetails *view = [[HomeworkDetails alloc] init];
int lastIndex = [indexPath indexAtPosition:[indexPath length] - 1];
NSLog(@"%u", lastIndex);
[self performSegueWithIdentifier: @"HomeworkDetailsSegue" sender:self];
view.currentIndex = lastIndex;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"HomeworkDetailsSegue"]) {
// note that "sender" will be the tableView cell that was selected
UITableViewCell *cell = (UITableViewCell*)sender;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; //**error**
HomeworkDetails *vc = (HomeworkDetails*)[segue destinationViewController];
vc.currentIndex = indexPath.row;
}
}
क्या 'currentIndex' आपकी तालिका पर एक प्रदाता होने के लिए है नियंत्रक या segue के गंतव्य दृश्य नियंत्रक पर? – jonkroll
यह गंतव्य ViewController पर एक संपत्ति है। गलतफहमी के लिए खेद है। साथ ही, परीक्षण करने के लिए, मैं मूल रूप से इस संपत्ति के लिए गंतव्य नियंत्रक पर एक टेक्स्ट व्यू सेट कर रहा हूं, लेकिन यह हमेशा 0 – Kgrover