2
我有一個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,我想這個數組與delegate.allSelectedVerseEnglish按鈕來改變click.When英語的按鈕被它改變了tableviewcontent用戶點擊(我的表名字是選項卡),以delegate.allSelectedVerseEnglish。這是可能的。請幫我找出這個問題。 在此先感謝。 編輯:
在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];
}
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 2011-12-23 04:45:56
你有沒有檢查數組是否存在?你有NSLog你的代碼在控制檯打印數組? – Hiren 2011-12-23 04:54:06
你做到了嗎? – Hiren 2011-12-23 05:02:31