2010-11-09 10 views
0

Je suis en train d'étendre UITableViewController et d'ajouter un uibutton au pied de la table, pour une raison quelconque, l'uibutton ne se déclenche que lorsque vous le touchez en haut ... comme si quelque chose masquait le reste Je ne comprends pas ce qu'il est j'ai le code suivant à la fonction viewForFooterInSection:UIButton ne se déclenche pas toujours

CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; 

UIView* footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, 44.0)]; 
footerView.autoresizesSubviews = YES; 
footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 
footerView.userInteractionEnabled = YES; 


goButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[goButton addTarget:self action:@selector(getReport)forControlEvents:UIControlEventTouchUpInside]; 
[goButton setTitle:@"GO!" forState:UIControlStateNormal]; 
[goButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
goButton.frame = CGRectMake(50, 20, 220.0, 50.0); 

UIImage *bg = [UIImage imageNamed: @"but_go.png"]; 
[goButton setBackgroundImage:bg forState:UIControlStateNormal]; 
[goButton setBackgroundColor:[UIColor clearColor]]; 

if (self.optimizations == nil || self.optimizations.count < 1){ 
goButton.enabled = NO ; 
} 

[footerView addSubview: goButton]; 

return footerView; 

Répondre

3

C'est parce que le cadre du bouton est tombé hors de sa vue parent. Vous devez augmenter la taille de l'image de votre footerView afin que toute la partie du bouton contienne footerView. Vous pouvez essayer de définir la couleur d'arrière-plan footerView sur bleu ou rouge pour voir la zone réelle du cadre.

Questions connexes