自动播放youtube错误?

时间:2010-10-23 09:17:00

标签: iphone objective-c youtube

    - (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:'

1 个答案:

答案 0 :(得分:0)

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