iPhone - How add a final line in a UITableView to add items, preventing rearranging of this line -
मेरे पास एक इस तालिका दृश्य में, मुझे कस्टम कक्ष में कुछ पंक्तियां दिखाई देती हैं, और मैं अंत में एक जोड़ना चाहूंगा जो उपयोगकर्ता को एक आइटम जोड़ने की अनुमति देगा (दूसरे दृश्य का उपयोग करके) ) तो मैं कुछ लाइनों ने लिखा है: इस तरह से, मैं "ऐड लाइन" सेल पर व्यवस्था बटन कैसे निकाल सकता हूं और इस के तहत जाने के लिए अन्य लाइनों को रोक सकता हूं? या कोड करने का एक बेहतर तरीका है? लागू और UITableView संपादित मोड में डाल दिया है।
Self.tableView.editing = हाँ;
- (NSInteger) tableView:। (UITableView *) tableView numberOfRowsInSection: (NSInteger) अनुभाग {वापसी "लाइनों की संख्या" + 1; } - (BOOL) तालिकादृश्य: (UITableView *) तालिकादृश्य चाहिए चाहिएखबरएडटिंग RowAtIndexPath: (NSIndexPath *) indexPath {वापसी हाँ; } - (UITableViewCellEditingStyle) tableView: (UITableView *) tableView editingStyleForRowAtIndexPath: (NSIndexPath *) indexPath {if (indexPath.row + 1 = [tableView numberOfRowsInSection: 0]!) {वापसी UITableViewCellEditingStyleDelete; } और {वापसी UITableViewCellEditingStyleInsert; }} - (शून्य) tableView: (UITableView *) tableView willDisplayCell: (UITableViewCell *) सेल forRowAtIndexPath: (NSIndexPath *) indexPath {if (indexPath.row + 1 == [tableView numberOfRowsInSection: 0]) {cell.textLabel.text = @ "एक पंक्ति जोड़ें ..."; } अन्य {कस्टम कक्ष में सामान करते हैं}}
UITableView किसी भी पंक्ति को पुनर्व्यवस्थित करने की अनुमति देता है। मैं "लाइन जोड़ने" के बाद पहली पंक्ति को स्थानांतरित कर सकता हूं, और पहले स्थान पर "जोड़ पंक्ति" को स्थानांतरित कर सकता हूं।
- (bool) tableView: (UITableView *) tableView canMoveRowAtIndexPath : (NSIndexPath *) indexPath {वापसी (! [indexPath पंक्ति] = INDEX_OF_SPECIAL_ROW)}
- (NSIndexPath *) tableView: (UITableView * ) tableView targetIndexPathForMoveFromRowAtIndexPath: (NSIndexPath *) sourceIndexPath toProposedIndexPath: (NSIndexPath *) proposedDestinationIndexPath {अगर ([proposedDestinationIndexPath पंक्ति] & LT; NUMBER_OF_ROWS) {proposedDestinationIndexPath वापसी; } NSIndexPath * otherPath = [NSIndexPath indexPathForRow: NUMBER_OF_ROWS-1 में पता: 0]; वापसी अन्यपाथ; }
Comments
Post a Comment