0
A
回答
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;
}
相關問題
- 1. Cocoa - 在另一個xib上顯示xib
- 2. 在Xcode中聲明對象從一個xib到另一個xib?
- 3. Xib文件在另一個xib中
- 4. 將變量發送到另一個xib
- 5. 打開另一個Xib形成一個Xib
- 6. 將兩個div粘貼到另一個
- 7. 如何切換到另一個XIB並完成以前的XIB?
- 8. 將xib從一個項目複製到另一個項目
- 9. UIButton點擊交換到另一個xib
- 10. 將兩個XIB連接到一個ViewController
- 11. 在另一個xib中使用xib對象
- 12. 加載從另一個XIB(iPhone)的視圖控制器的XIB
- 13. 反正還有另一個xib文件嵌套xib嗎?
- 14. 從另一個xib獲取UITextField值
- 15. 替換另一個.xib文件
- 16. 如何從另一個類加載xib
- 17. PyGame - 無法將一個表面粘貼到另一個表面
- 18. 當從另一個XIB導航時,UITable單元格不在XIB上顯示
- 19. 多個NSView到一個Xib文件
- 20. 如何將XIB複製到另一個項目?
- 21. 如何重複使用多個.xib作爲另一個.xib的模板?
- 22. 加載一個xib文件
- 23. nsdocument nswindowcontroller nsviewcontroller - 一個xib?
- 24. 當它與它碰撞時,將一個精靈粘貼到另一個上
- 25. 複製一個變量值並將其粘貼到另一個數據表上
- 26. 一個xib文件或多個xib文件
- 27. 複製並粘貼到一個列到另一個MS_ACCESS
- 28. 如何從另一個類中調用一個xib文件,ios
- 29. 如何從另一個類更新一個xib標籤
- 30. 加載xib文件到一個容器
謝謝!它確實有用! –
請問爲什麼這個工作? 即使我將ViewController.m行46〜49和UIViewController + testAlert.m行41註釋掉了。 –
我不熟悉代碼中的設置框架如何與自動佈局進行交互。 –