繁体   English   中英

UIViewController上的两个标题栏(UITableViewController的子视图)

[英]Two title bars on UIViewController (subview of UITableViewController)

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

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

titleBar问题

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

largeTitleBar

我已经删除了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;

}

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

标题栏来自旧笔尖。 我在情节提要中创建了它,添加了酒吧,然后改变了主意,决定删除它。

无论出于什么原因,无论是在模拟器上还是在手机上重新加载应用程序时,它都不会覆盖最初导致此问题的旧笔尖(即使它已从xCode中删除)。 我只是从手机和模拟器中删除了该应用程序,然后重新加载了它,标题栏不见了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM