我有一个按钮,一个pickerview和一个tableview。当我按下按钮时,pickerview的当前选择将被填充到表格视图中。下面是按钮的其中挑选值从pickerview使用pickerview填充tableview
- (IBAction)addCourse:(UIButton *)sender {
NSInteger numRow=[picker selectedRowInComponent:kNumComponent];//0=1st,1=2nd,etc
NSInteger SeaRow=[picker selectedRowInComponent:kSeaComponent];//0=fall,1=spring,2=summer
NSInteger CourseRow=[picker selectedRowInComponent:kCourseComponent];
NSString *num=Number[numRow];
NSString *season=Season[SeaRow];
NSString *course=Course[CourseRow];
NSString *msgCourse=[[NSString alloc ]initWithFormat:@"%@ ",course];
NSString *msgSeason=[[NSString alloc ]initWithFormat:@"%@ ",season];
NSString *msgYear=[[NSString alloc ]initWithFormat:@"%@ ",num];
}
然后我想填充msgCourse,等我的tableview代码
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
...Content from above msgCourse and etc
return cell;
}
如何解决在我的第二个部分的差距吗?或者请看一下任何示例?
非常感谢您的回复。它报告错误cell.textLabel.text = msgCourse;我认为msgCourse是一个局部变量?再次感谢。 – user4441082
你应该让它成为全球性的。 – casillas
感谢您的耐心等待。如果我需要在多行tableview中填充多条消息,是否需要修复某些内容? – user4441082