3
self.refreshControl = [[UIRefreshControl alloc]init]; 
    [self.objDiscussiontopic addSubview:self.refreshControl]; 
    [self.refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged]; 

- (void)refreshTable { 
    //TODO: refresh your data 
    [self.refreshControl endRefreshing]; 
} 

Ceci est le code que j'utilise pour ajouter un contrôleur de rafraîchissement dans ma vue déroulante. Mais quand je descends la vue de défilement, le contrôle d'actualisation n'apparaît pas et la méthode ciblée n'est pas appelée pourquoi?UIScrollview Tirer pour rafraîchir ne fonctionne pas

Je suis à la recherche pendant un certain temps, mais n'a pas obtenu de réponse appropriée.

Un scrollview plus chose ayant VFL Constraint quelque chose comme ceci:

//Pin scrolview to Parent View 
    [VFLConstraint allignSubViewViewHorizentallyWithSubView:self.objDiscussiontopic OverSuperView:[self view]]; 
    [VFLConstraint allignSubViewViewVerticallyWithSubView:self.objDiscussiontopic OverSuperView:[self view] WithTopPading:[CommonFunction convertIphone6ToIphone5:0] AndBotomPading:[CommonFunction convertIphone6ToIphone5:57]]; 


+ (void)allignSubViewViewHorizentallyWithSubView:(UIView *)subView OverSuperView:(UIView *)superView{ 

    NSDictionary *viewDict= NSDictionaryOfVariableBindings(subView); 
    [superView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[subView]|" options:0 metrics: 0 views:viewDict]]; 
} 

+ (void)allignSubViewViewVerticallyWithSubView:(UIView *)subView OverSuperView:(UIView *)superView WithTopPading:(float)topPading AndBotomPading:(float)bottomPading{ 

    NSDictionary *viewDict= NSDictionaryOfVariableBindings(subView); 
    NSDictionary *metrics=[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:topPading],@"topPading",[NSNumber numberWithFloat:bottomPading],@"bottomPading", nil]; 
    [superView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-topPading-[subView]-bottomPading-|" options:0 metrics: metrics views:viewDict]]; 
} 

Répondre

0

Je ne pense pas UIRefreshControl est conçu pour fonctionner avec des vues de défilement simples. docs d'Apple font spécifiquement référence à UITableViews when talking about refresh control.

Vous pouvez regarder tiers tirer pour rafraîchir les bibliothèques à ajouter à UIScrollView

0

Essayez de: [self.scrollView insertSubview:self.refreshControl atIndex:0];

Vérifiez la contentSize il peut être moins que la taille du cadre, si donc utilisez cette ligne de code: self.scrollView.alwaysBounceVertical = true