Rom*_*use 2 iphone objective-c ios
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
NSLog(@"will rotation");
for (UIButton *button in self.view.subviews) {
[button removeFromSuperview];
}
}
Run Code Online (Sandbox Code Playgroud)
我有这个代码的问题.我需要从我的视图中删除UIButtons.但是这段代码也删除了我的self.view的所有子视图.我怎么解决这个问题?
做这个:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
NSLog(@"will rotation");
for (id subview in self.view.subviews) {
if([subview isKindOfClass:[UIButton class]]) //remove only buttons
{
[subview removeFromSuperview];
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1698 次 |
| 最近记录: |