太长了,请看 http://blog.csdn.net/xdrt81y/article/details/9128695
- performSelector:
- performSelector:withObject:
- performSelector:withObject:withObject:
实际调用
- [self performSelector:@selector(displayViews) withObject:nil afterDelay:1.0f];
有三个方法分别是
- //父视图
- [self.view superview]
- //所有子视图
- [self.view subviews]
- //自身的window
- self.view.window
循环一个视图下面所有视图的方法
- NSArray *allSubviews(UIView *aView)
- {
- NSArray *results = [aView subviews];
- for (UIView *eachView in [aView subviews])
- {
- NSArray *riz = allSubviews(eachView);
- if (riz) {
- results = [results arrayByAddingObjectsFromArray:riz];
- }
- }
- return results;
- }
循环返回一个APPLICATION里面所有的VIEW
- // Return all views throughout the application
- NSArray *allApplicationViews()
- {
- NSArray *results = [[UIApplication sharedApplication] windows];
- for (UIWindow *window in [[UIApplication sharedApplication] windows])
- {
- NSArray *riz = allSubviews(window);
- if (riz) results = [results arrayByAddingObjectsFromArray: riz];
- }
- return results;
- }
找出所有的父视图
- // Return an array of parent views from the window down to the view
- NSArray *pathToView(UIView *aView)
- {
- NSMutableArray *array = [NSMutableArray arrayWithObject:aView];
- UIView *view = aView;
- UIWindow *window = aView.window;
- while (view != window)
- {
- view = [view superview];
- [array insertObject:view atIndex:0];
- }
- return array;
- }
IOS开发之UIView总结1,布布扣,bubuko.com
时间: 2024-10-13 20:50:26