2011-12-23 2 views
2

나는 it.There에있는 내용의 배열 UItableview가 두 개의 배열이 있습니다, 나는 버튼 클릭을 사용하여 배열을 전환하고 싶습니다. 내 코드는버튼 클릭으로 UITableView의 내용을 변경하는 방법은 무엇입니까?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

tab.backgroundColor = [UIColor clearColor]; 
tab.separatorColor = [UIColor clearColor]; 
cell.chapterAndVerse.text = [NSString stringWithFormat:@"%d",indexPath.row+1]; 
cell.chapterAndVerse.font = [UIFont fontWithName:@"Georgia" size:17.0]; 
cell.chapterAndVerse.frame=CGRectMake(0, 10, 30.0, 20.0); 
cell.textLabel.text = [NSString stringWithFormat:@" %@",[delegate.allSelectedVerseMalayalam objectAtIndex:indexPath.row]]; 

cell.textLabel.font = [UIFont fontWithName:@"testfont" size:18]; 
cell.backgroundColor = [UIColor clearColor]; 
} 

내 배열은 delegate.allSelectedVerseMalayalam, 내가 영어의 버튼은 (는) tableviewcontent을 변경하는 사용자가 클릭 click.When이 배열은 버튼에 delegate.allSelectedVerseEnglish로 변경하려면 (내 테이블 이름은 탭입니다.) delegate.allSelectedVerseEnglish.이게 어떻게 가능합니까?이 문제를 해결할 수 있도록 도와주세요. 미리 감사드립니다. 편집 :

cell.chapterAndVerse.text = [NSString stringWithFormat:@"%d",indexPath.row+1]; 
cell.chapterAndVerse.font = [UIFont fontWithName:@"Georgia" size:17.0]; 
cell.chapterAndVerse.frame=CGRectMake(0, 10, 30.0, 20.0); 
cell.textLabel.text = [NSString stringWithFormat:@" %@",[tempArray objectAtIndex:indexPath.row]]; 

// cell.textLabel.textColor = [UIColor darkGrayColor]; 
cell.textLabel.font = [UIFont fontWithName:@"testfont" size:18]; 
cell.backgroundColor = [UIColor clearColor]; 

답변

1

할 수있는 tableview에서

- (void)viewDidLoad { 
NSLog(@"%@", delegate.allSelectedVerseMalayalam); 
    tempArray = [[NSMutableArray alloc] init]; 
    [tempArray addObjectsFromArray:delegate.allSelectedVerseMalayalam]; 
    NSLog(@"%@", tempArray); 

    [self.tab reloadData]; 
} 
-(IBAction)_clickbtndefaultlnguageset:(id)sender 
{ 
    [tempArray removeAllObjects]; 
    [tempArray addObjectsFromArray:delegate.allSelectedVerseHindi]; 
    [self.tab reloadData]; 

} 

한 가지 일 개 추가 배열을하고 소스 파일에 정의 하여 할당 prees 버튼

후 .H 파일

NSMutableArray *tempArray; 

-(void)viewDidLoad{ 
//NSLog(@"%@", your Array); 
tempArray = [[NSMutableArray alloc] init]; 
[tempArray addObjectsFromArray:yourfirstarray]; 
NSLog(@"%@", tempArray); 
[self.tableview reloadData]; 
} 

-(void)pressedBtn{ 
//NSLog(@"%@", your Array); 
[tempArray removeAllObjects]; 
[tempArray addObjectsFromArray:yoursecondArray]; 
[self.tableView reloadData]; 
} 

테이블 배열에이 임시 배열을 사용하십시오.

+0

소스 파일에 배열을 정의하십시오. 델리게이트 배열이 먼저 존재하는지 확인하십시오. viewDidLoad 배열을 인쇄하십시오 – Hiren

+0

배열이 있는지 확인 했습니까? 콘솔에 어레이를 인쇄하려면 코드에 NSLog가 있습니까? – Hiren

+0

해 보셨습니까? – Hiren

관련 문제