0
UIView에 UITableView가 추가되었습니다. 데이터가 데이터베이스에서 돌아 오면 NSMutableArray에 데이터가 전달됩니다. 셀이 렌더링되면이 UIView로 출력되는 데이터로 셀 내부에 UIView를 만듭니다. 이제 CellView는 UIView로 렌더링되고 UIView가 표시되는지 확인할 수 있습니다. 하지만 UI가 데이터가 포함 된 다른 셀을 보려면 아래로 스크롤 할 수 없기 때문에 스크롤 막대가 작동하지 않습니다.IOS, UITabelView가 스크롤되지 않습니다.
코드 :
tableViewThreads = [[UITableView alloc] initWithFrame:CGRectMake(0, 104, screenRect.size.width, 336)];
tableViewThreads.delegate = self;
tableViewThreads.dataSource = self;
tableViewThreads.bounces = YES;
tableViewThreads.separatorStyle = UITableViewCellSeparatorStyleNone;
[viewTopThread addSubview:tableViewThreads];
tableViewThreads.userInteractionEnabled = YES;
[self.view bringSubviewToFront:tableViewThreads];
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(tableViewThreads == tableView){
return [threadsArray count];
}
return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
if(tableViewThreads == tableView){
ThreadInfo *threadInfo = (ThreadInfo*)[self.threadsArray objectAtIndex:indexPath.row];
[cell.contentView addSubview:[self setupThreadItem:threadInfo]];
//[cell.textLabel setText:tweet];
//[cell.detailTextLabel setText:@"via Codigator"];
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableViewThreads == tableView){
return 122;
}
return 0;
}
-(void)renderThreadInfo:(NSDictionary*)dic{
NSDictionary *thread = [dic objectForKey:@"thread"];
int t_ID;
int t_U_ID;
int t_C_ID;
NSString *t_Name;
NSString *t_Description;
NSDate *t_Created;
int t_Flagged;
int t_Rated;
for(NSDictionary *dict in thread)
{
if((NSNull *)[dict objectForKey:@"T_ID"] != [NSNull null]){
t_ID = [[dict objectForKey:@"T_ID"] intValue];
}
if((NSNull *)[dict objectForKey:@"T_U_ID"] != [NSNull null]){
t_U_ID = [[dict objectForKey:@"T_U_ID"] intValue];
}
if((NSNull *)[dict objectForKey:@"T_C_ID"] != [NSNull null]){
t_C_ID = [[dict objectForKey:@"T_C_ID"] intValue];
}
if((NSNull *)[dict objectForKey:@"T_Name"] != [NSNull null]){
t_Name = [dict objectForKey:@"T_Name"];
}
if((NSNull *)[dict objectForKey:@"T_Description"] != [NSNull null]){
t_Description = [dict objectForKey:@"T_Description"];
}
if((NSNull *)[dict objectForKey:@"T_Created"] != [NSNull null]){
NSString *timestampString = [dict objectForKey:@"T_Created"];
double timestampDate = [timestampString doubleValue];
t_Created = [NSDate dateWithTimeIntervalSince1970:timestampDate];
}
if((NSNull *)[dict objectForKey:@"T_Flagged"] != [NSNull null]){
t_Flagged = [[dict objectForKey:@"T_Flagged"] intValue];
}
if((NSNull *)[dict objectForKey:@"T_Rated"] != [NSNull null]){
t_Rated = [[dict objectForKey:@"T_Rated"] intValue];
}
ThreadInfo *threadObj = [ThreadInfo new];
threadObj.iD = t_ID;
threadObj.userId = t_U_ID;
threadObj.catId = t_C_ID;
threadObj.name = t_Name;
threadObj.description = t_Description;
threadObj.timeStampCreated = t_Created;
threadObj.flagged = t_Flagged;
threadObj.rated = t_Rated;
[threadsArray addObject:threadObj];
[tableViewThreads reloadData];
}
}
힌트 : 당신이 자동 레이아웃이 – Stonz2
Stonz2, 자동 레이아웃 @ ... 켜져있는 걸거야? – redoc01