【问题标题】:ios how can get the list of subview on view? [closed]ios如何获取视图中的子视图列表? [关闭]
【发布时间】:2013-02-03 07:26:18
【问题描述】:

你们中的任何人都知道如何获取视图中的子视图列表吗?有没有办法将列表放入数组中?

NSMutableArray *subviews= .... //all my subviews

【问题讨论】:

标签: ios xcode uiview subview


【解决方案1】:

你可以这样做

- (void)listSubviewsOfView:(UIView *)view {

    // Get the subviews of the view
    NSArray *subviews = [view subviews];

    // Return if there are no subviews
    if ([subviews count] == 0) return;

    for (UIView *subview in subviews) {

        NSLog(@"%@", subview);

        // List the subviews of subview
        [self listSubviewsOfView:subview];
    }
}

请通过此链接How to list out all the subviews in a uiviewcontroller in iOS?

【讨论】:

    猜你喜欢
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多