在我的应用程序中,我有一个纵向和横向不同大小的视图。我需要让后端控制器代码在电话更改时触发此视图中某些图形元素的“重绘”。我该怎么做呢?是否存在对UIView的某种委托调用,以了解其大小何时发生更改?
发布于 2014-09-23 01:14:00
您还可以像这样编写自定义代码:
- (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
}发布于 2016-01-15 22:17:19
你所需要做的就是在你的自定义控制器中实现以下方法:
override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) {
//do sth when rotated
}https://stackoverflow.com/questions/25979487
复制相似问题