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

Chirone

macrumors 6502
Original poster
Mar 2, 2009
279
0
NZ
i have a uitextview and i've set the text but it doesn't show up unless i click on the text view to edit it.

i don't want the text view to be editable and i want the text to just show up...

this is how i'm making it:

Code:
CGRect frame = CGRectMake(50, 50, 200, 200);
UITextView *textView = [[UITextView alloc] initWithFrame: frame];
textView.backgroundColor = [UIColor whiteColor];
textView.textColor = [UIColor colorWithRed: 0.8 green: 0.8 blue: 0.8 alpha: 1.0];
textView.font = [UIFont fontWithName:@"Helvetica" size: 17];
textView.editable = NO;
textView.text = NSLocalizedString(@"instructions", @"");

[textView setNeedsDisplay];
[parentView addSUbview: textView];
[textView release];

why does this not work yet you can do textView.text = @"blah" if textview is a uiTextView from an IBOutlet?
 
First, you meant addSubview, right? (Remember, Objective-C is case-sensitive.)

Second, it works fine for me, but I replaced parentView with self.view, since I'm not sure how you have parentView set up. Perhaps you could elaborate on that as well as where you have included the above code snippet.
 
yeah i meant addSubview, i replaced the actual method that i was calling with addSubview
but that method does the same thing, just calls addSubview

parentView is the same as self.view in this example, it's just that this method is called with the possibility of parentView being a different view like a scrollview or button

this method is called inside a loop which creates various other uiView children depending on certain conditions
the loop is inside another method that gets called from viewDidLoad

so essentially it's just doing that code in the viewDidLoad method

it's strange that it only does weird stuff for a uiTextView and nothing else
but since it doesn't need to be edited i decided i'd get a uiLabel, parent that to a uiScrollView and parent the uiScrollView to the parentView essentially it's the same thing but it works...

really weird...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.