2012-04-24 10 views
10

ho voluto ignorare SETFRAME modo che centra l'etichetta come bene però fare qualcosa di simile:come si fa a ignorare SETFRAME per un UILabel

- (void)setFrame:(CGRect)frame 
{ 
    [self setFrame:frame}; 
    self.center = CGPointMake(self.superview.center.x, kNavigationBarFrameHeight/2); 
} 

mi dà un ciclo infinito. Quindi come faccio?

+3

[super setFrame: frame] – Roshit

risposta

24

È necessario chiamare [super setFrame:frame].

Questo chiamerà l'implementazione di UILabel di setFrame e non la tua. Questo è ciò che sta causando il tuo ciclo infinito.