消息顯示在控制檯窗口中,但不顯示在uitextview當我運行該程序是什麼問題。消息不顯示在iOS中的UITextView?
-(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];
}
消息在控制檯窗口中顯示但不顯示在uitextview中當我運行程序時出現了什麼問題。
你從來沒有設置您的UITextView的文字... – 2014-10-30 08:17:06
你在哪裏創建smsdisplay?我無法看到UITextView * smsdisplay。如果你在XIB中做了這個。或故事板,那麼你不必smsdisplay = [[UITextView alloc] init] ;.你也必須設置textview的框架。 – 2014-10-30 08:24:35