UIWebView does not show scrolling bars on iphone Simulator - iphone

CGRect fullFrame = CGRectMake(10, 150, 300, 200);
UIWebView *fullTextView = [[UIWebView alloc] initWithFrame:fullFrame];
fullTextView.userInteractionEnabled = YES;
NSString *imagePath = [[MDImageManager sharedImageManager].imagesPath copy];
imagePath = [imagePath stringByReplacingOccurrencesOfString:#"/" withString:#"//"];
imagePath = [imagePath stringByReplacingOccurrencesOfString:#" " withString:#"%20"];
NSString *imageName = [[MDImageManager sharedImageManager] loadImage:[NSURL URLWithString:currentCoupon.fullImageURL]];
NSString *HTMLData = [NSString stringWithFormat: #"<img src=%# />", imageName];
[fullTextView loadHTMLString:HTMLData baseURL:[NSURL URLWithString: [NSString stringWithFormat:#"file:/%#//",imagePath]]];
[view addSubview:fullTextView];
The image loads and appears, but the web view has no scrolling bars!
The fullTextView is added to a viewcontroller, contained in a navigation + tabbar view controller, could it be the problem?
Any help greatly appreciated!
Gerald

That's not a navigation nor tabbar problem.
The uiwebview contains a uiscrollview as a provate attribute, and you can't access it normally.
You can either find the Uiscrollview by hacking the component and finding the UIScrollview subview or directly use by yourself an UIScrollView, wich has scrollIndicators methods.
You can refer to this post too :
How to show UIWebView's scroll indicators

Related

UITextView Scrolling Memory Issue on iOS7

I have a trouble with UITextView scrolling on iOS7 which didn't happen on iOS6.
When I set text on UITextView and scroll it fast on device, Xcode5 memory report shows it consuming huge memory. However, when I do the same on simulater, it's just fine.
Does anybody has the same issue? I use iOS7 and Xcode5.0, and clean installed iPhone5 for device.
This is the code for the test.
UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds];
NSString *textPath = [[NSBundle mainBundle] pathForResource:#"Alice's Adventures in Wonderland by Lewis Carroll" ofType:#"txt"];
NSString *string = [[NSString alloc] initWithContentsOfFile:textPath encoding:NSUTF8StringEncoding error:nil];
textView.text = string;
textView.font = [UIFont systemFontOfSize:20];
[self.view addSubview:textView];
Sample Project
https://github.com/umekun123/iOS7-UITextView-Scrolling--Test
Profiling Picture

UITextField cuts/hidden from the half first row - until touching

I have this really unanswered question.. after looking in the web for this problem i tring my luck with you..
i have a UITextView that gets the string from url.
but... the textfield is cuts/hidden fron the half first row and its fixed only when i touch it.
this is the code:
- (NSString *)getMonthValues{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"%#/%#",URL_ADDRESS2,URL_MONTH_ZODIAC]];
NSString *Value = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
Value = [Value stringByReplacingOccurrencesOfString:#"\\n" withString:#"\n"];
}
-(void)getMonthValue{
NSString *horoscope_daily = [self getMonthValues];
[Month_horoscope setText:[NSString stringWithFormat:#"%#",horoscope_daily]];
}
can someone please explain this problem and help me fix it ?!
It is either 1) covered by other view, or 2) has a frame too small to see the whole text.
To check out the cover issue, try setting background property to [UIColor redColor], on all other visible views.
And if it is the frame issue, right after you setText, issue:
[Month_horoscope sizeToFit];

what is the change required in this code to show text instead of image?

In My viewControllerOne,,,I am using tableview..and when I tap any row..I am using this code..to navigate to another page...
Feches *rOVc = [[Feches alloc] initWithNibName:#"Feches" bundle:nil];
rOVc.hidesBottomBarWhenPushed = YES;
rOVc.title = [NSString stringWithFormat:#"15 March 2011"];
rOVc.strURL = [[NSString alloc] initWithString:[[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"first_screen" ofType:#"png"]] absoluteString]];
[self.navigationController pushViewController:rOVc animated:YES];
[rOVc release];
Now When It navigate to Feches...
In that fetches's viewdidload I am using this code...
NSString *html = [NSString stringWithFormat:#"<html><head>\
<meta id='viewport' name='viewport' content='minimum-scale=0.2; maximum-scale=5; user-scalable=1;' />\
</head><body style=\"margin:0\"><img id=\"yt\" src=\"%#\"></body></html>", self.strURL];
NSLog(#"html:%#",html);
// Load the html into the webview
if(self.myWeb == nil) {
self.myWeb = [[UIWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:self.myWeb];
}
[self.myWeb loadHTMLString:html baseURL:[NSURL URLWithString:self.strURL]];
This is showing me image named...first_screen which is there in my images folder...
Now...I want to use text paragraph instead of image ...but with the same kind of html and all this..can anyone please suggest me what change do I have to do now for showing paragraphs instead of an Image??
Change your html string content. Replace <img id=...> with <p>text</p>.
You're leaking UIWebView (if self.myWeb retains). Change your code to:
self.myWeb = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease];

Creating a WebView programmatically and displaying NSStrings inside the view

I have created a WebView programmatically. This works perfect. The code is below.
What I need to try and do now is inject NSStrings into it. I have an array of 30 strings. 15 Headings and 15 body-texts.
Is it possible to get these displayed inside the WebView? I'm guessing I need to change them into a HTML, i may be reformat them all into 1 long NSString with HTML-tags and linebreaks and newling-tags maybe?
Anybody able to help me with some pointers/code snippets to get me on the right track and moving the the correct direction please?
- (void) initUIWebView
{
aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 290)];//init and
create the UIWebView
aWebView.autoresizesSubviews = YES;
aWebView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
[aWebView setDelegate:self];
NSString *urlAddress = #"http://www.google.com"; // test view is working with url to webpage
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[aWebView loadRequest:requestObj];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
[[self view] addSubview:aWebView];
}
Thanks
-Code
Instead of using the loadRequest method you will have to use the loadHTMLString method of UIWebView
The following code might help you in displaying the NSString in UIWebView
NSString *html = #"<html><head></head><body>The Meaning of Life<p>...really is <b>42</b>!</p></body></html>";
[webView loadHTMLString:html baseURL:nil];
Hope this will resolve your issue...

asy there any way to change color of UIWebView of Iphone Application

I am using webview to display Data from RSS Feed Can I change color of WebView to Black From white.
I have declare outlet in xib file named RemainingRssViewController
and i am diplaying it from root view controller the code is
NSString *htmlstring =[[blogEntries objectAtIndex: blogEntryIndex] objectForKey: #"description"];
NSURL *baseUrl;
baseUrl = [[NSURL alloc]initWithString:feedurl];
[anotherViewController.maintext loadHTMLString:htmlstring baseURL:baseUrl];
//maintext is the UIWebVeiw outlet in anotherViewController.
Ok, looks good.
With this code:
NSString *htmlstring =[[blogEntries objectAtIndex: blogEntryIndex] objectForKey: #"description"];
You set up an HTML string to go in the UIWebView. However, it's not actually HTML, because right now it's just text. To solve this, we'll instead make the "htmlstring" to be styled HTML with the text from the XML feed.
For example:
NSString *textString = [[blogEntries objectAtIndex: blogEntryIndex] objectForKey:#"description"];
NSString *htmlstring = [NSString stringWithFormat:#"<html><head><style type='text/css'>body { color:#FFFFFF; background-color: #000000; }</style></head><body>%#</body></html>",textString];
Then, when the "htmlstring" is placed inside the UIWebView, it will be styled as you would like it to be.