- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSInteger numberOfRows = 0;
if (self.tableView == tableView)
{
numberOfRows = self.allMovies.count;
NSLog(@"NRA:%d", self.allMovies.count);
}
else
{
[self filterPlayers];
numberOfRows = self.filteredMovies.count;
NSLog(@"NRF:%d", self.filteredMovies.count);
}
return numberOfRows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"SearchAndAddMovieCell";
FFFSearchAndAddMovieCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSLog(@"Cell is nil");
cell = [[FFFSearchAndAddMovieCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
if (cell == nil)
NSLog(@"Still NIL");
}
Movie *movie;
if (self.tableView == tableView)
{
Movie *normalMovie = (Movie *)[self.allMovies objectAtIndex:indexPath.row];
movie = normalMovie;
NSLog(@"normal:%@", movie);
}
else
{
Movie *filteredMovie = [self.filteredMovies objectAtIndex:indexPath.row];
movie = filteredMovie;
NSLog(@"filter:%@", movie);
}
NSLog(@"1:%@|%@", movie.name, cell.movieName.text);
cell.movieName.text = movie.name;
NSLog(@"2:%@|%@", movie.name, cell.movieName.text);
cell.genre.text = movie.genre;
这完全填充了我的初始电影列表。但是,当我在UISearchBar中输入一个关于我的UITableViewController的字符时,我没有得到任何结果,尽管在我的NSLog中看到了可能/应该是的结果。有什么想法吗?
这是LOG输出......
2014-02-24 17:15:24.274 FantasyFeed[2367:60b] NRF:1
2014-02-24 17:15:24.278 FantasyFeed[2367:60b] Cell is nil
2014-02-24 17:15:24.281 FantasyFeed[2367:60b] filter:The Godfather
2014-02-24 17:15:24.283 FantasyFeed[2367:60b] 1:The Godfather|(null)
2014-02-24 17:15:24.286 FantasyFeed[2367:60b] 2:The Godfather|(null)
为什么cell.movieName.text在这里一直空?在我在searchBar中输入任何内容之前,LOG看起来像这样......
2014-02-24 17:15:22.015 FantasyFeed[2367:60b] NRA:12
2014-02-24 17:15:22.021 FantasyFeed[2367:60b] normal:The Godfather
2014-02-24 17:15:22.023 FantasyFeed[2367:60b] 1:The Godfather|Label
2014-02-24 17:15:22.024 FantasyFeed[2367:60b] 2:The Godfather|The Godfather
这些是我对大胆的好奇心。正常运行使它们像底部2一样,但searchBar运行将它们作为前2个。
2014-02-24 17:15:24.283 FantasyFeed [2367:60b] 1:教父| (null)
2014-02-24 17:15:24.286 FantasyFeed [2367:60b] 2:教父| (null)
2014-02-24 17:15:22.023 FantasyFeed [2367:60b] 1:教父| 标签
2014-02-24 17:15:22.024 FantasyFeed [2367:60b] 2:教父| 教父
答案 0 :(得分:1)
您的代码表明您有两个单独的表。我怀疑它们都在你的故事板文件中,而且它有一个标识符为SearchAndAddMovieCell
的原型单元格而另一个没有。{/ p>