2
私はit.Thereに内容の配列でUItableviewを持って、2つの配列があります、私はボタンのクリックを使用して配列を切り替えたいです。 私のコードはボタンクリックで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である英語のためのボタンがユーザによってクリックされるclick.When、私はこの配列は、ボタンでdelegate.allSelectedVerseEnglishで変更したいことがtableviewcontent(私のテーブルを変更名前はタブです)をdelegate.allSelectedVerseEnglishに設定してください。これはどのように可能ですか。この問題を理解するために手伝ってください。 ありがとうございます。 EDIT:
- (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];
}
テーブルビューで
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];
ソースファイルに配列を定義します。デリゲート配列が存在するかどうか最初にチェックしますか? viewDidLoadで配列を出力します – Hiren
配列が存在するかどうかチェックしていますか?コンソールに配列を印刷するコードをNSLogで持っていますか? – Hiren
していますか? – Hiren