I set sizeClass to Regular on iOS9~ iPad, but it doesn't reflect.

Asked 2 years ago, Updated 2 years ago, 104 views

On ipad, there is an item that sizeClass is specified as regular in order to change this layout, but both the emulator and the actual machine do not respond, and for some reason the setting of any is reflected.
We have verified that the Regular Regular settings are reflected successfully in the iOS 8.1 simulator and iOS 8.4.

The xcode project is here
http://fushi.x0.com/php_system/20160117-stackoverflow-question/xibTest2.zip

There are two views defined by xib (AaView and BView).
AaView is available from the ViewController

class AaViewController:UIViewController {
    varchildView—AaView?
    varbView—BView?
    override func loadView() {
        self.edgesForExtendedLayout=UIRectEdge.None;
        iflet view=UINib(nibName: "AaView", bundle:nil).instantiateWithOwner(self, options:nil).first as?AaView{
            self.view=view;
        }
    }
    override func viewDidLoad(){
        super.viewDidLoad()
        self.childView=self.view as!AaView!
        self.bView = BView (frame: (UIApplication.sharedApplication().keyWindow?.bounds)!)
        UIAApplication.sharedApplication().keyWindow?addSubview(self.bView!)
    }
}

Define

as shown in .

BView is

class BView:UIView{
@IBOutlet var contentView—UIView!
override init (frame:CGRect) { // for using CustomView in code
    super.init (frame:frame)
    self.commonInit()
}
required init? (coder adecoder:NSCoder) { // for using CustomView in IB
    super.init(coder:aDecoder)
    self.commonInit()
}
private func commonInit(){
    NSBundle.mainBundle().loadNibNamed("BView", owner:self, options:nil)
    contentView.frame =self.bounds
    self.addSubview(contentView)
}

}

as defined in .

Except for the wrong sizeClass, both A and B are displayed, and iPhone 6 Plus iOS 9.2 only displays the any label normally.(B-any in the upper left and A-any in the lower right)
labeled any in the upper left and lower right

However, in ipad2 iOS 9.0/ipadair2 iOS 9.2, A-Regular is displayed as intended, but in B, B-any is displayed.The layout designation method is wrong and the position is out of alignment...
Enter a description of the image here

These labels are
on xCode. Enter a description of the image here
Enter a description of the image here
Defined as shown in , regreg appears only when both horizontal and horizontal are regular
Any is specified to be any in both vertical and horizontal, but not Regular.

Both AaView and BView are specified in the same way.

As for AaView, it is displayed as desired, but for some reason SizeClass is not reflected in BView.
Could you please let me know if there are any parameters or insufficient settings?

The xcode version will be 7.2

Thank you for your cooperation.

ios swift xcode iphone

2022-09-29 21:20

1 Answers

This is the reason why SizeClass is not reflected in BView, but it seems that the following code is used to add bView directly under UIWindow in viewDidLoad() of AaViewController.

UIAApplication.sharedApplication().keyWindow?addSubview(self.bView!)

If you rewrite the appropriate part to add it to the view normally, it should work.

view.addSubview(bView!)

Why doesn't SizeClass work properly when I add View directly under UIWindow? In this case, I understand that traceCollectionDidChange is not called...I don't know the exact reason.


2022-09-29 21:20

If you have any answers or tips

Popular Tags
python x 4647
android x 1593
java x 1494
javascript x 1427
c x 927
c++ x 878
ruby-on-rails x 696
php x 692
python3 x 685
html x 656

© 2024 OneMinuteCode. All rights reserved.