मैं कुछ आरपीएन कैलक्यूलेटर में ऐसा कुछ करता हूं जो मैंने बनाया है।मेरे पास सभी संख्याओं के साथ एक टेबल व्यू है और जब स्टैक में कोई संख्या जोड़ा जाता है, तो सबकुछ एक सेल को पॉप करता है। जब मैं दृश्य लोड करता हूं तो मैं कॉल करता हूं:
[self.myTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:NumOfStackItems - 1 inSection:0]
atScrollPosition:UITableViewScrollPositionTop animated:NO];
मेरे विचार में WillAppear। इस तरह मेरा टेबल दृश्य स्टैक के नीचे दिखाया गया है और कोई एनीमेशन नहीं देखा जाता है। इसे व्यूविल्लियर में डालकर, हर बार जब मैं दृश्य पर नेविगेट करता हूं, तो यह तालिका के नीचे दिखाई देता है।
जब मैं ढेर करने के लिए संख्याओं को जोड़ने, मैं सिर्फ यह एक सरणी है कि सभी नंबरों को धारण में जोड़ने और फिर इस तरह उचित पंक्ति में पाठ डाल:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Cell initialization here...
NSUInteger row_num = [indexPath row];
cell.rowNumber.text = [NSString stringWithFormat:@"%g", [DataArray objectAtIndex:NumberOfStackItems-row_num-1];// subtract the row number off to get the correct array index
return cell
}
मैं यह भी सुनिश्चित करें कि जब भी मैं एक नए मान के साथ टेबलव्यू को अपडेट करें, मैं पहले रीलोडडाटा फ़ंक्शन को कॉल करता हूं, और उसके बाद ऊपर दिए गए scrollToRowAtIndexPath फ़ंक्शन को कॉल करता हूं, इस प्रकार मैं तालिका के नीचे रहता हूं।
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self goToBottom];
}
-(void)goToBottom
{
NSIndexPath *lastIndexPath = [self lastIndexPath];
[self.tableView scrollToRowAtIndexPath:lastIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
-(NSIndexPath *)lastIndexPath
{
NSInteger lastSectionIndex = MAX(0, [self.tableView numberOfSections] - 1);
NSInteger lastRowIndex = MAX(0, [self.tableView numberOfRowsInSection:lastSectionIndex] - 1);
return [NSIndexPath indexPathForRow:lastRowIndex inSection:lastSectionIndex];
}
viewWillAppear
पर इस प्रदर्शन उपयोगकर्ता से पहले तालिका देखता है यह किया जाएगा द्वारा:
आप एक 180 डिग्री के साथ तालिका दृश्य फ्लिप करने की कोशिश कर सकते, फ्लिप अपने कस्टम टेबल सेल 180 डिग्री सेल्सियस देखते हैं ताकि वे सामान्य दिखें और इंडेक्स पथों के लिए अपने तर्क को घुमाएं। आपके टेबलव्यू के नीचे पंक्ति 0 होगी। – Moxy
यह एक बहुत काम की तरह लगता है। बस अपने ऑब्जेक्ट्स को पहली ऑब्जेक्ट के लिए अंतिम ऑब्जेक्ट को स्विच करना और इसी तरह से चालू करें। फिर आप इसे उलट क्रम में प्रदर्शित करेंगे। – Martol1ni
@ मार्टोल 1ni यह कोड की केवल 2 पंक्तियां है! – Moxy