2015-07-11 2 views

ответ

0

Добавьте эту строку в файл гривой UIViewController + testAlert.m

containerFrame.size.width = view.frame.size.width; 

только после того, как

containerFrame.size.height = view.frame.size.height; 

поэтому код функции showAlertViewB будет как

if (show) { 
    NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"AlertViewB" owner:self options:nil]; 
    alertViewB = (AlertViewB*)[nibViews objectAtIndex:0]; 
//  [alertViewB removeConstraint:alertViewB.containerHeightConstraint]; 
//  NSLayoutConstraint *newContainerHeightConstraint = [NSLayoutConstraint constraintWithItem:alertViewB attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:view.frame.size.height]; 
//  [alertViewB addConstraint:newContainerHeightConstraint]; 
    CGRect containerFrame = alertViewB.container.frame; 
    containerFrame.size.height = view.frame.size.height; 
    containerFrame.size.width = view.frame.size.width; 
    [alertViewB.container setFrame:containerFrame]; 

    [alertViewB setTranslatesAutoresizingMaskIntoConstraints:YES]; 
    alertViewB.delegate =self; 
    [alertViewB showWithView:view]; 
} else { 
    [alertViewB removeFromSuperview]; 
    alertViewB = nil; 
} 
+0

Спасибо! Он работает! –

+0

Могу ли я спросить, почему это работает? Даже если я прокомментирую ViewController.m строку 46 ~ 49 и UIViewController + testAlert.m строка 41. –

+0

Я не знаком с тем, как кадр настройки внутри кода взаимодействует с автозапуском. –

Смежные вопросы