2017-07-21 12 views
9

तो, ग्राहक का नमूना यूआईटीबल व्यू को इसकी एक पंक्ति में मौजूद होने के लिए हर समय उपस्थित होना चाहता है, इसलिए उपयोगकर्ता UITableView की किसी भी स्थिति में इस महत्वपूर्ण बटन से बातचीत कर सकता है। एक बार जब वह स्क्रॉल करता है और बटन के साथ वास्तविक पंक्ति को देखता है, तो फ़्लोटिंग फ़ूटर गायब हो जाता है और उपयोगकर्ता को 'वास्तविक' सेल के साथ बातचीत करने की अनुमति देता है, न कि फ़्लोटिंग संस्करण।UITableView कस्टम UIView डुप्लिकेट

मैं निम्नलिखित कोड के साथ आ गया है:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView 
{  
    if([self isPostularmeRowVisible]) 
    { 
     [self hidePostularmeFooterView]; 
    } 
    else 
    { 
     [self showPostularmeFooterView]; 
    } 
} 

-(BOOL)isPostularmeRowVisible 
{   
    NSArray *indexes = [self.tableView indexPathsForVisibleRows]; 
    for (NSIndexPath *index in indexes) 
    { 
     if (index.row == 0 && index.section>=DetalleEmpleoPostularmeCell) 
     { 
      return YES; 
     } 
    } 
    return NO; 
} 

-(void) showPostularmeFooterView 
{ 
    NSAssert(_state==ESTADO_POSTULACION_NO_POSTULADO, @"NJDetalleEmpleoViewController: This shouldn't happen"); 

    if(!self.footerView) 
    { 
     NJDetalleEmpleoPostularmeTableViewCell *footerView = [self.tableView dequeueReusableCellWithIdentifier:kDetalleEmpleoPostularmeCell]; 
     [footerView configureCell:self.detaleAviso]; 
     float h = self.view.frame.size.height-footerView.cellHeight; 
     footerView.frame = CGRectMake(0,h,self.view.frame.size.width,footerView.cellHeight); 
     footerView.delegate = self; 
     self.footerView = footerView; 
     [self.view addSubview:self.footerView]; 
     [self.view bringSubviewToFront:self.footerView]; 
    } 
} 

-(void) hidePostularmeFooterView 
{ 
    if(self.footerView) 
    { 
     [self.footerView removeFromSuperview]; 
    } 

    self.footerView = nil; 
} 

लेकिन इस कोड एक बग है मैं यह पता लगाने की प्रतीत नहीं कर सकते हैं: एक बार उपयोगकर्ता नल UITextBox पर है और कुछ पाठ इसे करने के लिए शुरू में प्रवेश करती है गलत तरीके से व्यवहार करें, यानी: 2 या अधिक सेल स्क्रीन पर दिखाई देते हैं, जब कोई नहीं होना चाहिए! असल में, जब मैं 'hidePostularmeFooterView' विधि को कॉल करता हूं तो यह गायब नहीं होता है (केवल कुछ पाठ दर्ज करने के बाद, अगर मैं इसके साथ बातचीत नहीं करता हूं, तो यह ठीक काम करता है)।

enter image description here

यह लगता है के बाद मैं पाद के 2 संस्करण देखते हैं कुछ पाठ दर्ज, यहाँ सबूत है:

enter image description here

+0

यह दिखता है से, यह आप कैसे दिखाने के साथ कुछ हो सकता है/कीबोर्ड को छुपाएं और यह आपके विचारों के साथ कैसे इंटरैक्ट करता है। एक साइड नोट के रूप में, क्या आपको हर समय उस दृश्य को बनाने की ज़रूरत है? यदि आप इसे एक बार बनाते हैं और दृश्य को दिखाते और छुपाते हैं तो यह अच्छा व्यवहार करेगा। –

उत्तर

3

enter image description here

मैं footerView स्पर्श नहीं होगा, लेकिन इसके बजाय कस्टम का मानना ​​है कि इस तरह के तरह, पर आता है बनाने के लिए:

dataSource = [NSMutableArray new]; 
for (int n = 0; n < 100; n++){ 
    [dataSource addObject:[NSString stringWithFormat:@"%i",n]]; 
} 

table = [UITableView new]; 
table.frame = self.view.bounds; 
table.delegate = self; 
table.dataSource = self; 
[self.view addSubview:table]; 

popUpView = [UIImageView new]; 
popUpView.frame = CGRectMake(0, h-200, w, 200); 
popUpView.image = [UIImage imageNamed:@"Grumpy-Cat.jpg"]; 
popUpView.contentMode = UIViewContentModeScaleAspectFill; 
popUpView.clipsToBounds = true; 
popUpView.layer.borderColor = [UIColor redColor].CGColor; 
popUpView.layer.borderWidth = 2.0f; 
[self.view addSubview:popUpView]; 

हमेशा की तरह tableView, और scrollViewDidScroll विधि में स्थापित, आप कुछ इस तरह छड़ी सकता है:

NSIndexPath * specialRow = [NSIndexPath indexPathForRow:50 inSection:0]; 
NSArray * indices = table.indexPathsForVisibleRows; 
if ([indices containsObject:specialRow]){ 
    if (isShowing){ 
     isShowing = false; 
     [UIView animateWithDuration:1.0f 
           delay:0.0f 
      usingSpringWithDamping:1.0f 
       initialSpringVelocity:0.8f 
          options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionBeginFromCurrentState 
         animations:^{ 
          popUpView.transform = CGAffineTransformMakeTranslation(0, popUpView.frame.size.height + 10); 
         } 
         completion:^(BOOL finished){ 
         }]; 
    } 
} else if (!isShowing) { 

    isShowing = true; 
    [UIView animateWithDuration:1.0f 
          delay:0.0f 
     usingSpringWithDamping:1.0f 
      initialSpringVelocity:0.8f 
         options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionBeginFromCurrentState 
        animations:^{ 
         popUpView.transform = CGAffineTransformIdentity; 
        } 
        completion:^(BOOL finished){ 
        }]; 
} 

कहाँ isShowing popUpView राज्य के एक बूलियन ट्रैक रखते हुए है। यह त्वरित और गंदे कोड है, कहीं और विशेष घोषित करना चाहिए। इस मामले में इसे 100 पंक्तियों में से 50 वें के रूप में परिभाषित किया जाता है।

रिकॉर्ड के लिए, मुझे नहीं लगता कि यह अच्छा डिजाइन है कि जैसे नकली कार्यक्षमता है, लेकिन हे, ग्राहक सबसे अच्छा जानता है: डी

+1

धन्यवाद जोहनी रॉकएक्स, मैं इसे आजमाऊंगा और जवाब को ASAP के रूप में चिह्नित करूँगा। धन्यवाद! –

5

इसे और अधिक समझ में आप सिर्फ इस को दूर करने के लिए के रूप में कर सकता है एक सेल & पाद लेख और UITableView के नीचे इसे अपने UIView के रूप में बदलें, और UITableView की फ्रेम ऊंचाई केवल पूरी स्क्रीन को लेने के बजाय, इस दृश्य की उत्पत्ति के नीचे आती है। इस तरह आप हर समय दृश्य को देखने और बातचीत करने में सक्षम होंगे। क्या UITableViewCell होने के लिए आपको कोई कारण है?

+0

मैं सहजता से चारों ओर विचारों को देखने का बहुत शौक नहीं हूं, लेकिन मैं निश्चित रूप से इस विचार को एक कोशिश दूंगा। धन्यवाद @richiereitz –

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