2
저는 회사의 간단한 사내 경제 응용 프로그램을 프로그래밍하고 있지만 몇 가지 문제가 있습니다. 다음과 같이 동적으로 생성 된 객체의 정보로 UITableView를 채 웁니다.reloadData에서 tableView를 지우지 않았습니까?
- (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] autorelease];
}
Payments *project = [appDelegate.projects objectAtIndex:indexPath.row];
if([project.parentProject isEqualToString:bottomTabBar.selectedItem.title]) {
NSLog(@"%@ är lika med %@ index: %d",project.parentProject, bottomTabBar.selectedItem.title, indexPath.row);
// Configure the cell...
NSMutableString *changeInValue = [[NSMutableString alloc] initWithFormat:@"%d",[[project.amountsek objectAtIndex:0] intValue]-[[project.amountsek objectAtIndex:1] intValue]];
if([changeInValue intValue] >= 0) {
[changeInValue insertString:@"+" atIndex:0];
cell.imageView.image = [UIImage imageNamed:@"up.png"];
} else {
cell.imageView.image = [UIImage imageNamed:@"down.png"];
}
NSMutableString *foreignCurrency = [[NSMutableString alloc] initWithString:@""];
if(![project.currency isEqualToString:@"SEK"]) {
[foreignCurrency appendFormat:@" - %@%d",project.currency,[[project.payments objectAtIndex:0] intValue]];
}
NSString *detailString = [[NSString alloc] initWithFormat:@"%@%d (%@)%@",@"SEK",[[project.amountsek objectAtIndex:0] intValue],changeInValue, foreignCurrency];
[changeInValue release];
[foreignCurrency release];
cell.textLabel.text = project.name;
cell.detailTextLabel.text = detailString;
[detailString release];
}
project = nil;
return cell;}
그리고 모든 것이 매력처럼 작동합니다! 하나! 다른 tabButton을 누르면 표가 다시로드되고 일치하는 요소 만 표시됩니다. (일치하는 잘 작동, 로그 모든 올바르게 인쇄합니다.), 이전 테이블 셀 비어있는 새 것을 추가하기 전에. 나는이 문제를 해결하려면 어떻게
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
NSLog(@"Tab clicked: %d", item.tag);
[sourcesTable reloadData];
}
:
여기에 다시로드 TabItem에 대한 코드입니까? 저는 iPhone 프로그래밍에 익숙하지 않아 도움이 될 것 같습니다.
아무도 없습니까? :(정말? – Hjalmar