UITextView not displaying text

Discussion in 'iPhone/iPad Programming' started by forrestgrant, Oct 28, 2008.

  1. macrumors member

    Joined:
    Jun 24, 2008
    #1
    Here is my code
    Code:
    		CGRect textFrame = CGRectMake(70, 25, 250, 30);
    		UITextView *textView = [[UITextView alloc] initWithFrame:textFrame];
    		[textView setTextColor:[UIColor whiteColor]];
    		[textView setFont:[UIFont systemFontOfSize:12]];
    		textView.text = @"Hello World";
    		[textField setBackgroundColor:[UIColor blackColor]];
    
    When I run the app... I can see the block where text should be... but no text written? Anyone else having this issue?
     
  2. macrumors regular

    Joined:
    Mar 24, 2008
    #2
    You never actually added the control to a view. Assuming this is in a view controller, you probably want to add a line like:

    Code:
    [self.view addSubview:textView]
    Also you can use properties for those other items too, not just text:

    Code:
    textView.font = [UIFont systemFontOfSize:12]
    Probably best to stay consistent between the 2 style of property assignment.
     
  3. thread starter macrumors member

    Joined:
    Jun 24, 2008
    #3
    Sorry I didn't add that line when pasting code, but I did add it to the view. The TextView appears (as a black box in the middle of the screen) But no text.

    To be sure I wasnt going crazy, if I change UITextView to UITextField the text displays just fine. I don't want to use UITextField because it does not allow multiple line text.

    Thanks.
     
  4. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    FWIW, yes others on this forum and other forums have reported this. I haven't seen a clear explanation or solution.
     
  5. macrumors newbie

    Joined:
    Oct 27, 2008
    #5
    I had the same problem, my UITextView was positioned on UIScrollView outside of the visible screen and it didn't show text, when I put it on the visible part of the screen, the text is showed. I Guess it must be on the visible part of the screem.finally ended up using UILabel, works fine.
     
  6. macrumors 68040

    Joined:
    May 29, 2003
    #6
    Silly question but is this the 2.1version of the SDK.

    Just thought that I'd ask because Apple never notified me that 2.1 came out. I had to go pick it up myself.

    Sadly though it sounds like you ran into another bug in the SDK. Isn't that fun?

    Dave
     

Share This Page