iosobjective-cuiviewsialertview

Set the width of SIAlertView


How can I set the width of SIAlertView? I tried this for example and it only set the height not the width.

SIAlertView *alert = [[SIAlertView alloc] initWithFrame:CGRectMake(20, 20, 240, 100)];  

And I also tried to set it when it fires SIAlertViewWillShowNotification like below

- (void)SIAlertViewWillShow:(NSNotification *)notif
{
    SIAlertView *alertView = (SIAlertView *)notif.object;
    NSLog(@"alert view %@ ", alertView);
    CGRect f = alertView.frame;
    f.size.width = self.size.width * 0.62;
    alertView.frame = f;        
    [[NSNotificationCenter defaultCenter] removeObserver:self name:SIAlertViewWillShowNotification object:alertView];
}

Both won't work, any ideas ?


Solution

  • The frame of the alert is statically set using CONTAINER_WIDTH (in validateLayout). You would need to edit this to replace the constant with a variable that you could set.