消息不显示在iOS中的UITextView?
消息显示在控制台窗口中,但不显示在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框架。 如果您从XIB创建TextView,请不要调用alloc-init方法。
UITextView *smsdisplay = [[UITextView alloc] initWithFrame: YOUR_FRAME];
// some stuff...
[self.view addSubview: smsdiplay];
谢谢,但我解决这个问题已经看到我的其他问题http://stackoverflow.com/questions/26649974/my-screen-not-move-next-screen-on-buttons - 单击式-IOS?noredirect = 1#comment41903952_26649974 – 2014-10-30 10:12:47
您没有设置textview的框架。
NSLog(@"SMS LIST %@",title.Data);
后添加下一个代码更新您的文本字段:
_myTextfield.text = [NSString stringWithFormat:@"%@\n%@", _myTextfield.text, title.data];
感谢它的工作 – 2014-10-30 08:52:02
不客气:) – 2014-10-30 08:55:00
你从来没有设置您的UITextView的文字... – 2014-10-30 08:17:06
你在哪里创建smsdisplay?我无法看到UITextView * smsdisplay。如果你在XIB中做了这个。或故事板,那么你不必smsdisplay = [[UITextView alloc] init] ;.你也必须设置textview的框架。 – 2014-10-30 08:24:35