Just we have to find Button within WebView and Trigger it.
Here is the Code.
.h
#import <UIKit/UIKit.h>
@interface RSSDetailViewController : UIViewController <UIWebViewDelegate,UIScrollViewDelegate> @property (nonatomic, retain) IBOutlet UIWebView *webViewLink;
- (IBAction)btnPlay:(id)sender;
@end
.m
// self.link is link of youtube video.
- (void)viewDidLoad
{
[self.webViewLink loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.link]]];
}
}
- (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;
}
- (IBAction)btnPlay:(id)sender {
UIButton *btnTouch=[self findButtonInView:webViewLink];
[btnTouch sendActionsForControlEvents:UIControlEventTouchUpInside];
}
Reference
:http://stackoverflow.com/questions/3010708/youtube-video-autoplay-on-iphones-safari-or-uiwebview
Reference
:http://stackoverflow.com/questions/3010708/youtube-video-autoplay-on-iphones-safari-or-uiwebview
No comments:
Post a Comment