Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
I have narrowed down my current issue, to something to do with the UITextView.

I have a TableView, opening a detail view.
I have a navigation bar in place.

The detail view opens fine, and everything is displayed.
If I click on the navigation bar, to go back to the previous page.

And the app hangs.
But doesn't crash out, or cause a fatal issue in the debugger... just freezes.
(It is not the same result, if say I released an object on the previous page an it is no longer there, this just flat out freezes)

Can't click on my details in my Cells... can't click on the navigation bar to go to the previous-previous page.

If I remove the UITextView object from the view/nib file... works fine, no issues. I add it back, but don't connect to anything (just so that it is in the NIB), it causes the issues.

I have even created a new blank nib, and just added the UITextView... and it causes the issue.

I am using this UITextView to display multiple lines of text, it won't be editable.

Any ideas?

Do I need to implement some of the delegate functions, even though I am not going to be using them?

The parent page, is a standard ViewController, with a single View
 

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
Thanks for the tip. Does the UILabel have scrolling ability ? I didn't see a setting for that.

Note: I am downloading the SDK 2.1 update rightnow, so I can't check the UILabel myself at the moment. I am also hoping this will fix the UITextView issue...
 

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
Okay... the SDK Update didn't fix the issue.

I have continued to play with it, and I identified another piece to the puzzle.

I am doing all the work to gather the data (form a webservice), and then opening the new page, from a detached thread:

The method is getDetails.
I am allocating and initializing the thread PRIOR to starting the thread.

[NSThread detachNewThreadSelector:mad:selector(getDetails) toTarget:self withObject:nil];

If I don't do this as a detached thread... works fine.
If I remove the UITextView, it works fine (thread or not a thread)
If I leave the UITextView in (I have now added all the delgates as well), it freezes when launched from a thread, works fine when run in-line (not from the detached thread)
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
UILabel doesn't scroll.

In general it's bad to do UI things from secondary threads. Cocoa has some clear statements in the docs about what's thread-safe and what's not. I didn't find the same statements about UIKit.

If you can, stick to the main thread for UI code. If you need to, use performSelectorOnMainThread from your secondary thread to do things to the UI.

From your description I would say create the UI on the main thread, do your data gathering/downloading on the background thread. When you have enough data to update the UI use performSelectorOnMainThread to do this.

Also, NSURLConnection will download data from a web server for you on a secondary thread and call you back on the main thread. If you can use this class you won't have to worry about threads at all.
 

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
UILabel doesn't scroll.

In general it's bad to do UI things from secondary threads. Cocoa has some clear statements in the docs about what's thread-safe and what's not. I didn't find the same statements about UIKit.

If you can, stick to the main thread for UI code. If you need to, use performSelectorOnMainThread from your secondary thread to do things to the UI.

From your description I would say create the UI on the main thread, do your data gathering/downloading on the background thread. When you have enough data to update the UI use performSelectorOnMainThread to do this.

Also, NSURLConnection will download data from a web server for you on a secondary thread and call you back on the main thread. If you can use this class you won't have to worry about threads at all.


Thank you for the suggestions.... I will work on those in the morning, and try it out. I appreciate the assistance.
 

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
Well... I couldn't wait till morning.

I just tried it, and it solved my issues.
Thank you very much, and I learned something new..

Thank you again
 

psantacr

macrumors newbie
Feb 16, 2008
15
0
Let me just tell you...

Well... I couldn't wait till morning.

I just tried it, and it solved my issues.
Thank you very much, and I learned something new..

Thank you again

This thread saved me a lot of time....

Thanks++!

:apple:COCOA RULES.:apple:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.