3 つの Web ビューを使用して、スクロールビューで 50 などの複数の HTML ページを表示するにはどうすればよいですか。サンプルコードがあれば、私を参照してください。私の現在のコードはこれです。それはメモリリークを引き起こします。もちろん、私はそれがばかげていることを知っています。私はこれで2日以上立ち往生しています。私を助けてください。
-(void)AddWebviews
{
[m_CtrlActivity stopAnimating];
m_CtrlLblProgress.hidden=YES;
int divisor = WebViewAddCount % 3;
MagazineAppDelegate *appdelegate = (MagazineAppDelegate *)[[UIApplication sharedApplication]delegate];
IstructPageDetails *objPageDetails=[appdelegate.m_mutarrPageDetails objectAtIndex:WebViewAddCount];
if (divisor==0)
{
m_CtrlWebViewone=[[UIWebView alloc]initWithFrame:CGRectMake(768*WebViewAddCount,0,768,1024)];
// m_CtrlWebView.scrollView.delegate=self;
// m_CtrlWebView.delegate=self;
NSString *m_strMagazineFolder=[[GlobalFunctions GetCachesFolder]stringByAppendingPathComponent:MAGAZINE_FOLDER_NAME];
NSString *finalpath=[NSString stringWithFormat:@"%@/%@/%@/%@",m_strMagazineFolder,appdelegate.m_StrSelectedMagazineUrl,objPageDetails.m_strFolderName, objPageDetails.m_strPageName ];
NSURL *url = [NSURL fileURLWithPath:finalpath isDirectory:NO];
[m_CtrlWebViewone loadRequest:[NSURLRequest requestWithURL:url]];
m_CtrlWebViewone.scrollView.pagingEnabled=YES;
m_CtrlWebViewone.scrollView.bounces=NO;
m_CtrlWebViewone.scalesPageToFit=YES;
m_CtrlWebViewone.backgroundColor=[UIColor clearColor];
self.m_CtrlScrollview.pagingEnabled=YES;
[self.m_CtrlScrollview addSubview:m_CtrlWebViewone];
[m_CtrlWebViewone release];
}
else if(divisor==1)
{
m_CtrlWebViewtwo=[[UIWebView alloc]initWithFrame:CGRectMake(768*WebViewAddCount,0,768,1024)];
// m_CtrlWebView.scrollView.delegate=self;
// m_CtrlWebView.delegate=self;
NSString *m_strMagazineFolder=[[GlobalFunctions GetCachesFolder]stringByAppendingPathComponent:MAGAZINE_FOLDER_NAME];
NSString *finalpath=[NSString stringWithFormat:@"%@/%@/%@/%@",m_strMagazineFolder,appdelegate.m_StrSelectedMagazineUrl,objPageDetails.m_strFolderName, objPageDetails.m_strPageName ];
NSURL *url = [NSURL fileURLWithPath:finalpath isDirectory:NO];
[m_CtrlWebViewtwo loadRequest:[NSURLRequest requestWithURL:url]];
m_CtrlWebViewtwo.scrollView.pagingEnabled=YES;
m_CtrlWebViewtwo.scrollView.bounces=NO;
m_CtrlWebViewtwo.scalesPageToFit=YES;
m_CtrlWebViewtwo.backgroundColor=[UIColor clearColor];
self.m_CtrlScrollview.pagingEnabled=YES;
[self.m_CtrlScrollview addSubview:m_CtrlWebViewtwo];
[m_CtrlWebViewtwo release];
}
else if(divisor==2)
{
m_CtrlWebViewthree=[[UIWebView alloc]initWithFrame:CGRectMake(768*WebViewAddCount,0,768,1024)];
// m_CtrlWebView.scrollView.delegate=self;
// m_CtrlWebView.delegate=self;
NSString *m_strMagazineFolder=[[GlobalFunctions GetCachesFolder]stringByAppendingPathComponent:MAGAZINE_FOLDER_NAME];
NSString *finalpath=[NSString stringWithFormat:@"%@/%@/%@/%@",m_strMagazineFolder,appdelegate.m_StrSelectedMagazineUrl,objPageDetails.m_strFolderName, objPageDetails.m_strPageName ];
NSURL *url = [NSURL fileURLWithPath:finalpath isDirectory:NO];
[m_CtrlWebViewthree loadRequest:[NSURLRequest requestWithURL:url]];
m_CtrlWebViewthree.scrollView.pagingEnabled=YES;
m_CtrlWebViewthree.scrollView.bounces=NO;
m_CtrlWebViewthree.scalesPageToFit=YES;
m_CtrlWebViewthree.backgroundColor=[UIColor clearColor];
self.m_CtrlScrollview.pagingEnabled=YES;
[self.m_CtrlScrollview addSubview:m_CtrlWebViewthree];
[m_CtrlWebViewthree release];
}
WebViewAddCount++;
[self.m_CtrlScrollview setContentSize:CGSizeMake(WebViewAddCount*768, 1004)];
}