1

所以我有一个显示图片的表格视图控制器,然后当您选择一个单元格时,它会打开一个带有图像视图的 UIViewController 和一个带有返回或保存图像的按钮的导航栏。问题是我得到了第二个标题栏。我似乎无法删除它,我无法更改文本,老实说,我似乎无法找到它的来源。当我选择它时,它会选择导航栏,但如果我删除或隐藏导航栏,它会隐藏带有按钮的栏,并且这个“标题”栏会保留。

这是在模拟器中运行的样子:

标题栏问题

关于如何摆脱这个东西或至少改变它的标题的任何想法?唯一似乎改变它的是当我加载一个非常小的图像时,它会扩展以填充剩余的视图空间,如下所示:

大标题栏

我已经删除了 UIImageView 甚至笔尖中的视图,它仍然存在。我什至删除了笔尖本身,没有任何变化。我只能猜测超级视图正在以某种方式加载它,但我找不到任何可能导致它的东西。如果它来自单元格方法,它将具有图像的标题,而不仅仅是“标题”。

这是 Superview(它是一个表格视图控制器)中的代码,它用问题初始化屏幕:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
NSString *title = [completePicturesList objectAtIndex:row];
NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
NSString *docDirectory = [sysPaths objectAtIndex:0];
NSString *imagePath = [NSString stringWithFormat:@"%@/%@", docDirectory, title];

UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];

GCDetailViewController *childController = [[GCDetailViewController alloc] init];
childController.mainImage = image;
[self.navigationController pushViewController:childController animated:YES];

}

这是显示副本的 UIViewController 的 viewWillAppear:

- (void)viewWillAppear:(BOOL)animated { 
[super viewWillAppear:animated];

mainImageDisplay.image = mainImage;

UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Save"
                                                               style:UIBarButtonItemStyleBordered target:self action:@selector(saveImageToPhotoAlbum)];
self.navigationItem.rightBarButtonItem = editButton;
NSString *titleText = [NSString stringWithFormat:@"Image Review"];
self.title = titleText;

此类中唯一的其他方法是保存照片。此外,也没有为此分配笔尖,因此它不存在。至于self.title,如果我改变它,它会改变上面写着“Image Review”的文字,而不是它下面的“title”。如果我尝试隐藏导航栏,它会隐藏图像查看栏并且标题栏会保留。

只是为了好玩,这里是 cellForRow 方法,看看它是否在那里:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *CellIdentifier = @"newCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

NSUInteger row = [indexPath row];
NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
NSString *docDirectory = [sysPaths objectAtIndex:0];
NSString *cellTitle = [completePicturesList objectAtIndex:row];
NSString *imagePath = [NSString stringWithFormat:@"%@/%@", docDirectory, cellTitle];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];

cell.textLabel.text = cellTitle;
cell.imageView.image = image;

return cell;

}

4

1 回答 1

1

如果不能回答我自己的问题,请原谅,但我确实找到了解决方案。

标题栏来自一个旧笔尖。我在情节提要中制作了它,添加了条形图,然后改变了我想如何处理它并删除它的想法。

无论出于何种原因,当我在模拟器和手机上重新加载应用程序时,它都没有覆盖最初导致此问题的旧笔尖(即使它已从 xCode 中删除)。我只是从手机和模拟器中删除了该应用程序并重新加载它,标题栏就消失了。

于 2012-10-14T00:06:39.123 回答