-1

message display in console window but not display in uitextview when i run the program what the problem in that.

-(void)getSmsData
{
    array = [[NSMutableArray alloc] init];

    NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
                                                            NSUserDomainMask, YES);
    NSString *documentDir = [docPaths objectAtIndex:0];
    self.databasePath = [documentDir stringByAppendingPathComponent:@"SMS.sqlite"];

    FMDatabase *database = [FMDatabase databaseWithPath:self.databasePath];
    [database setLogsErrors:TRUE];
    [database open];

    NSString *anQuery = [[NSString alloc]initWithFormat:@"SELECT * FROM SMSnJokes where
    Id=%@",self.Id ];

    FMResultSet *results = [database executeQuery:anQuery];

    while([results next])
    {
        SmsTitle *title=[[SmsTitle alloc]init];
        title.Id = [results stringForColumn:@"Id"];
        title.Data=[results stringForColumn:@"Data"];
        title.CategoryId = [results stringForColumn:@"CategoryId"];
        title.Title = [results stringForColumn:@"Title"];
        [array addObject:title];
        NSLog(@"SMS LIST %@",title.Data);
    }


    [database close];
}

-(void)getSmsdisplay
{
    smsdisplay=[[UITextView alloc]init];

    for (SmsTitle *title in array)
    {
        NSString *tempStr = title.Data;
        smsdisplay.text=tempStr;
        smsdisplay.editable = NO;
        [smsdisplay setTextColor:[UIColor blackColor]];
        smsdisplay.font = [UIFont systemFontOfSize:15];        
    }

    [self.view addSubview:smsdisplay];   
}

message display in console window but not display in uitextview when i run the program what the problem in that.

Tordek
  • 10,628
  • 3
  • 36
  • 67
  • You never set text of your UITextView... – David Ansermot Oct 30 '14 at 08:17
  • Where did you create your smsdisplay? I couldnt see UITextView *smsdisplay. If you made this in XIB. or storyboard then you dont have to smsdisplay=[[UITextView alloc]init];. Also you have to set frame of textview. – Yucel Bayram Oct 30 '14 at 08:24

3 Answers3

3

You have to set the UITextView frame. If you create the TextView from the XIB, don't call the alloc-init methods.

UITextView *smsdisplay = [[UITextView alloc] initWithFrame: YOUR_FRAME];
// some stuff...
[self.view addSubview: smsdiplay];
Luca D'Alberti
  • 4,749
  • 3
  • 25
  • 45
  • thanks but i solve this problem already see my other question http://stackoverflow.com/questions/26649974/my-screen-not-move-next-screen-on-buttons-click-in-ios?noredirect=1#comment41903952_26649974 – Chetan Gharat Oct 30 '14 at 10:12
2

After NSLog(@"SMS LIST %@",title.Data); add the next code to update your textfield :

_myTextfield.text = [NSString stringWithFormat:@"%@\n%@", _myTextfield.text, title.data];
David Ansermot
  • 6,052
  • 8
  • 47
  • 82
1

You didn't set frame of the textview.

gabbler
  • 13,626
  • 4
  • 32
  • 44