Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

cocoa touch - iphone application distribution build contains a bug

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

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Did you try to just take your distribution build configuration and change its code signing options to iPhone developer, and then test that build on your device?

As far as I know, you can also upload binaries signed with a developer certificate by now. So you could take a working developer build and submit that one to Apple.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...