我有UIPickerView
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return seasons.count;
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if ([season selectedRowInComponent:0] == 6) {
matches = [[NSMutableArray alloc] initWithCapacity: 20];
[matches insertObject:[NSMutableArray arrayWithObjects:@"aaa", @"bbb", @"1-0", @"15-03-2010", nil] atIndex:0];
} else if
.
.
.
}
然后我有UITableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return matches.count;
}
- (CustomCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"customCell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.team1.text = matches[indexPath.row][0];
cell.team2.text = matches[indexPath.row][1];
cell.score.text = matches[indexPath.row][2];
return cell;
}
现在,UITableView
填充了我在matches
初始化的viewDidLoad
数组中的对象。如何根据UIPickerView
?
答案 0 :(得分:2)
更新void Main::readFile()
{
while (v.size() != 0) {
string name;
name = v.at(v.size()-1);
v.pop_back();
std::ofstream out(name + ".txt");
ifstream file;
file.open("letter.txt");
string word;
string comma;
char x;
word.clear();
while (!file.eof())
{
x = file.get();
while (x != ' ' && x != std::ifstream::traits_type::eof())
{
if (word == "@name@") {
word = name;
}
if (word == "@festival@") {
word = "THISISATEST!!!!!!!!!!!!!!";
}
word = word + x;
x = file.get();
}
out << word + " ";
word.clear();
}
}
数组后,只需致电<head>
<style>
input{ border: 5px solid red;}
</style>
</head>
<div class="in">
<input class="input" type="text" name="text" method="post">
</div>
。
[self.tableView reloadData];
这假设matches
既是表视图数据源/委托又是选择器视图数据源/委托