UITextView Scrolling Memory Issue on iOS7 - iphone

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

Related

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];

iphone timer plist file display

I'm going to ask this question again,I thought I had figured it out but I guess not. This is for a timer app that gets the timer info from a plist file. Everything works but I want the .plist extension not to show in my tableview. Here are two code snippets that I believe are the issue. These are in an array called NSArray *files;
self.files = [[NSBundle mainBundle] pathsForResourcesOfType:#"plist" inDirectory:#"Timers1"];
// Configure the cell.
cell.textLabel.text = [[files objectAtIndex:indexPath.row] lastPathComponent];
return cell;
Thanks for the help
NSString *text = [[files objectAtIndex:indexPath.row] lastPathComponent];
text = [text substringToIndex:[text rangeOfString:#"."].location];
cell.textLabel.text = text;

UIImageView animation causing crash

I have a UIAnimation view that plays an array of PNG images as an animation. There are about 200 frames and total size is about 8 MB. The animation works just fine on simulator and iPhone 4, but when I test on iPhone 3GS, the app crashes due to the animation.
I've tried using UIImage imageNamed:, but I read that using imageWithData might be faster, so I have this:
NSString *imageName=[NSString stringWithFormat:#"fishBg_%i.png", i];
NSString *fileLocation = [[NSBundle mainBundle] pathForResource:imageName ofType:nil];
NSData *imageData = [NSData dataWithContentsOfFile:fileLocation];
[animationArray addObject:[UIImage imageWithData:imageData]];
What can my problem be? When I reduce the number of frames to about 100, then the animation plays and the app doesn't crash. But when I bring up the frame count to 200, then the app crashes. What's a better way to do this? The animation is a PNG sequence of transparent images, so I'm not sure if I'd be able to convert this to a video and keep its transparency and place other images under it.
Since we need to conserve as much memory as possible here (assuming that’s why you’re crashing), try managing memory more explicitly:
NSString *imageName=[[NSString alloc] initWithFormat:#"fishBg_%i.png", i];
NSString *fileLocation = [[NSBundle mainBundle] pathForResource:imageName ofType:nil];
[imageName release];
UIImage *theImage = [[UIImage alloc] initWithContentsOfFile:fileLocation];
[animationArray addObject:theImage];
[theImage release];

Memory leaks in Iphone

label = (UILabel *)[cell.contentView viewWithTag:1];
label.text =labelString;
size = [label.text sizeWithFont:[UIFont fontWithName:#"ArialMT" size:14] constrainedToSize:CGSizeMake(320,9999) lineBreakMode:UILineBreakModeWordWrap];
label.frame = CGRectMake(5, 5, 295, (size.height+25));
UIFont leave 256 Bytes leak.
And some other leaks also present in my app related to web kit and Foundation library.
NSString *path = [[NSBundle mainBundle] pathForResource:#"Prayers" ofType:#"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
NSString *htmlString = [[NSString alloc] initWithData:
[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
These lines leave UIKit WebKit and DataDetectorsCore related leaks.
Please suggest any solution for this problem. Total leaked memory is arround 3 KB, can i
leave this in app or not.
I doubt you have leak on the UITableViewCell instances.
You made some custom UITableViewCells, maybe you need to check those UITableViewCells.
The UIFont leak you mentioned may not be leak at all. The possibility that UIFont wasn't released is internal caching by UIFont when you use the fontWithName method.
I noticed that UIFont may leak memory when called not from the main thread. Put assertion before your code. This will allow you to catch the error.
NSAssert([NSThread isMainThread]);

UIWebView does not show scrolling bars on iphone Simulator

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