开发者

how to scroll a saved document horizontally in iphone webview

i have a webviewcontroller in which i am loading a saved html page or a pdf or any other document by this code.

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

i an trying to load a document and show it using horizontal scroll not vertical scr开发者_运维技巧oll.

can someone help me how to do this.

Thanks


Add this in your page -

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

You can increase the page width to suite your needs


You can use the following code, as it worked fine for me:

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


first you create the view horizontally and then you load that document to this view..then you can able to scroll horizontally....

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜