SOLVED: This has been solved following the assistance of many people. I'm now writing this, so that people with similar problems can benefit from it. In order for me to recreate this bug, I had to run the distribution build on my device. This was accomplished following MrMage's advice, which told me to change the certificate to the developer, and not the distribution. This allowed me recreate the error and debug it. The problem turned out to be that the compiler was ignoring all calls to set a CGSize's values. I was able to prevent this by setting the "Optimization Level" in the target preferences to "None", instead of "Fastest, Smallest".
Hello there,
I have a very peculiar in my application. A few days ago, my app got approved into the app store, but to my horror I soon discovered that there was a major bug in it. I went to my computer, but when a ran the code(both in the simulator and on the device), it all worked perfectly. I have tried everything: recompile and commit an update, clean all targets, reinstall the SDK, etc.
Here is a more detailed description of the problem. I have a detail table view in my application which loads some data from an online source. It displays a loading view while it downloads, and then reloads the tableview once the datasource is set. The table's cells contain UITextViews, which changes size to fit the text. When I run the app on the computer, or debugging on the device, the text is downloaded and displayed perfectly, but when I download from the App Store and launch it, it will only display text the first time, and then leave blank for the rest. I know the data gets downloaded because the texviews resize themselves to fit the text, they just don't display it.
Do anybody know what might be causing this error? How can I know whether my distribution build contains an error, which doesn't show up in the debug build?
Yours, BEN.
PS: I have compared the target settings for the debug and distribution builds. The only difference I see is "Optimization level" under "Code generation". I have tried to change this for the debug build, but it doesn't reveal the problem.
EDIT: I solved the problem by doing what MrMage suggested. It turns out that this code is indeed the cause of the error. When running in the debugger, the width and height properties of 's' are constantly zero, and I can't change this no matter what. I'm looking into why this happens.
- (void) setText:(NSString *)string
{
CGSize s = [string sizeWithFont:textView.font constrainedToSize:CGSizeMake(290, FLT_MAX)];
s.height += kStaticSize;
//SizeWithFont is very unreliable so have to do some dirty tweaking
if (s.height > 100 && s.height <= 250)
s.height += 20;
else if (s.height > 250 && s.height <= 500)
s.height += 40;
else if (s.height > 500 && s.height <= 800 )
s.height += 50;
else if (s.height > 800 && s.height <= 1200)
s.height += 60;
else if (s.height > 1200 && s.height <= 1700)
s.height += 100;
else if (s.height > 1700)
s.height += 200;
s.width = 290;
CGRect r = textView.frame;
r.size = s;
[textView setFrame:r];
[self.textView setText: string];
[self.textView setNeedsDisplay];
}