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?
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.