내 목표는 HTML 페이지에 Google DFP 배너보기 (배너 광고)를 추가하고 iPad에서 HTML로 스크롤하도록하는 것입니다.
HTML은 UIWebView
iOS에서 정상적으로 표시됩니다 .
UIView
페이지의 일부인 것처럼 스크롤되도록 콘텐츠와 함께 DFP 배너보기 (에서 상 속됨 )를 배치하려면 어떻게해야합니까?
지금까지 내가 한 일 :
UIWebView
이 *scrollview
속성을.webview.scrollview
.배너보기를 웹보기의 scrollview
.
for (UIView *view in self.webview.scrollView.subviews) {
CGRect frame = view.frame;
frame.origin.y += bannerAdvertsHeight;
frame.size.height -= bannerAdvertsHeight;
view.frame = frame;
}
[self.webview.scrollView addSubview:self.dfpBannerView];
현재 iPad에 액세스 할 수 없지만 시뮬레이터에서 작동 중입니다. 그것이 '좋은'해결책인지 확실하지 않습니다. 내 접근 방식에 문제가 있다고 생각되면 알려주세요.
다음은보기 계층 구조입니다 UIWebView
.
(gdb) po [webView recursiveDescription]
<UIWebView: 0x68220e0; frame = (0 0; 320 460); >
| <UIScrollView: 0x4b2bee0; frame = (0 0; 320 460); >
| | <UIImageView: 0x4b2dca0; frame = (0 0; 54 54); >
| | <UIImageView: 0x4b2da20; frame = (0 0; 54 54); >
| | <UIImageView: 0x4b2d9c0; frame = (0 0; 54 54); >
| | <UIImageView: 0x4b12030; frame = (0 0; 54 54) >
| | <UIImageView: 0x4b11fd0; frame = (-14.5 14.5; 30 1); >
| | <UIImageView: 0x4b11f70; frame = (-14.5 14.5; 30 1); >
| | <UIImageView: 0x4b11f10; frame = (0 0; 1 30); >
| | <UIImageView: 0x4b11eb0; frame = (0 0; 1 30); >
| | <UIImageView: 0x4b11e50; frame = (0 430; 320 30); >
| | <UIImageView: 0x4b2d0c0; frame = (0 0; 320 30); >
| | <UIWebBrowserView: 0x6005800; frame = (0 0; 320 460); >
계층 구조를 살펴보면 배너를에 추가해야 UIWebBrowserView
하거나 그렇지 않은 경우 그 위에 추가해야 합니다.
for (id view in self.webview.scrollView.subviews) {
if (![view isKindOfClass:[UIImageView class]]) {
CGRect frame = view.frame;
frame.origin.y += bannerAdvertsHeight;
frame.size.height -= bannerAdvertsHeight;
view.frame = frame;
}
}
[self.webview.scrollView addSubview:self.dfpBannerView];
이것은 일종의 해킹이므로 나중에 iOS 업데이트에서 나중에 문제가 발생할 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다