【问题标题】:Auto play youtube error?自动播放 youtube 错误?
【发布时间】:2011-04-29 12:43:03
【问题描述】:
    - (void)webViewDidFinishLoad:(UIWebView *)YouTubePlayer {
    UIButton *b = [self findButtonInView:YouTubePlayer];
    [b sendActionsForControlEvents:UIControlEventTouchUpInside];
}

- (UIButton *)findButtonInView:(UIView *)view {
    UIButton *button = nil;

    if ([view isMemberOfClass:[UIButton class]]) {
        return (UIButton *)view;
    }

    if (view.subviews && [view.subviews count] > 0) {
        for (UIView *subview in view.subviews) {
            button = [self findButtonInView:subview];
            if (button) return button;
        }
    }

    return button;
}

此代码不起作用,我在UIButton *b = [self findButtonInView:YouTubePlayer]; 行收到 2 个警告,警告是:

“YouTubePlayer”的本地声明隐藏了实例变量 “SecondViewController”可能不会响应“-findButtonInView:”

【问题讨论】:

    标签: iphone objective-c youtube


    【解决方案1】:
    1. 您应该在 findButtonInView 方法中调用 [YouTubePlayer view]
    2. 在您的 SecondViewController.h 文件中,添加行 - (UIButton *)findButtonInView:(UIView *)view;

    【讨论】:

    • 这是怎么回事: - (UIButton *)findButtonInView:(UIView *)view { UIButton *button = nil; [YouTube播放器视图]; if ([view isMemberOfClass:[UIButton class]]) { return (UIButton *)view; } if (view.subviews && [view.subviews count] > 0) { for (UIView *subview in view.subviews) { button = [self findButtonInView:subview]; if(按钮)返回按钮; } } 返回按钮; }
    • 哇。你能用那个更新你的问题吗,它会让它更容易阅读..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-10
    • 2019-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-11
    • 1970-01-01
    相关资源
    最近更新 更多