2011-04-05 54 views
2

我有一個webviewcontroller,其中我通過此代碼加載保存的html頁面或pdf或任何其他文檔。如何在iphone中水平滾動保存的文檔webview

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"yahoo" ofType:@"html"]isDirectory:YES]]]; 

我試圖加載文件,並顯示它使用水平滾動而不是垂直滾動。

有人可以幫助我如何做到這一點。

感謝

回答

0

在你的頁面添加此 -

<link media="only screen and (max-width: 1000px)" 
    rel="stylesheet" type="text/css" href="iphone.css"/> 

可以提高網頁寬度以適合您的需求

+0

感謝SAURABH您的回覆,但如果我必須通過編程方式顯示頁面的頁面加載PDF如何將我通過他們水平滾動。 – Rishi 2011-04-05 05:30:56

+0

請編輯你的問題這個...現在你的問題沒有完全描述你的問題! – Saurabh 2011-04-05 05:34:48

0

首先創建水平視圖,然後您加載文檔這查看..然後你就可以水平滾動....

UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
scroll.pagingEnabled = YES; 
NSInteger numberOfViews = 3; 
for (int i = 0; i < numberOfViews; i++) { 
CGFloat yOrigin = i * self.view.frame.size.width; 
UIView *awesomeView = [[UIView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
awesomeView.backgroundColor = [UIColor colorWithRed:0.5/i green:0.5 blue:0.5 alpha:1]; 
[scroll addSubview:awesomeView]; 
[awesomeView release]; 
} 
scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height); 
[self.view addSubview:scroll]; 

[for more details][1] 


    [1]: http://idevzilla.com/2010/09/16/uiscrollview-a-really-simple-tutorial/ 
0

Yo ü可以使用下面的代碼,因爲它爲我工作得很好:

[self.tableView scrollToRowAtIndexPath:someIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]