【发布时间】:2012-06-14 13:58:32
【问题描述】:
我想做的是..我想在两个表视图之间传递数据。
在我的根视图控制器中,我使用一个数组,然后为 RootViewController 填充它并在
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
我这样做的方法:
if (indexPath.row == 0)
{
self.schedule.title = @"Show1";
NSLog(@"SCHEDULE CONTROLLER TITLE = %@", schedule.title);
NSLog(@"FIRST ROW ");
}
if (indexPath.row == 1) {
self.schedule.title = @"Show2";
NSLog(@"SECOND ROW");
}
if(indexPath.row == 2){
self.schedule.title = @"Show3";
NSLog(@"THIRD ROW");
}
schedule = [[ScheduleViewController alloc] initWithNibName:@"ScheduleViewController" bundle:nil];
[self.navigationController pushViewController:schedule animated:YES];
schedule 是另一个表视图,所以.. 我正在做的是比较 schedule 的标题来决定 schedule 表视图的内容,但有些它没有获取数据。
这里是ViewDidLoad日程查看方法:
[super viewDidLoad];
if ([self.title isEqualToString:@"Show1"])
{
showSchedule = [[NSArray alloc] initWithObjects:@"SUNDAY",@"MONDAY",@"TUESDAY" , nil];
}
if ([self.title isEqualToString:@"Show2"])
{
showSchedule = [[NSArray alloc] initWithObjects:@"WEDNESDAY",@"THURSDAY",@"FRIDAY" , nil];
}else {
showSchedule = [[NSArray alloc] initWithObjects:@"SATURDAY", nil];
}
[self.tableView reloadData];
self.title 返回 null,因此它在最后进入 else 循环。
任何想法我在这里做错了什么..?
提前感谢您的宝贵时间
【问题讨论】:
-
您似乎在创建
schedule之前设置了title属性。 -
哇...!!感谢您指出菲利普米尔斯。错过这一点真的很愚蠢。
标签: iphone ios5 uiviewcontroller uitableview