【发布时间】:2011-12-23 03:43:16
【问题描述】:
我有一个 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更改此数组。当用户单击英语按钮时,它会将tableviewcontent(我的表名是tab)更改为delegate.allSelectedVerseEnglish .这怎么可能。请帮我解决这个问题。 提前致谢。 编辑:
- (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];
【问题讨论】:
标签: iphone arrays uitableview event-handling uibutton