简体   繁体   English

IOS8-自动版式大小类更改通知/代理

[英]IOS8 - AutoLayout Size Class Change Notification/Delegate

In my application I have a view that is different sizes in portrait and landscape. 在我的应用程序中,我有一个纵向和横向尺寸不同的视图。 I need to have the backend controller code trigger a "redraw" of some graphical elements in this view when the phone changes. 我需要让后端控制器代码在手机更换时触发此视图中某些图形元素的“重绘”。 How do I do this? 我该怎么做呢? Is there some sort of delegate call to the UIView to know when its size has changed? 是否有某种委托调用UIView来知道其大小已更改?

you can also write a custom like this: 您也可以这样编写一个自定义:

- (void)viewDidLoad
{
    [super viewDidLoad];
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
    // Do any additional setup after loading the view.
}

- (void)orientationChanged:(NSNotification *)notification
{
    //Redraw Here
}

All you need to do is implement following method in your custom controller: 您需要做的就是在自定义控制器中实现以下方法:

override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) {
    //do sth when rotated
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM