iphone - UIViewController 上的两个标题栏(UITableViewController 的 subview )

标签 iphone ios uiviewcontroller

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

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

titleBarIssue

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

largeTitleBar

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

下面是来自 Superview(它是一个 TableView Controller )的代码,它初始化了有问题的屏幕:

- (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;

这个类中唯一的其他方法是保存照片。此外,也没有为此分配 Nib ,因此它不存在。至于 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;

最佳答案

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

标题栏来自旧 Nib 。我在 Storyboard 中制作了它,添加了栏,然后改变了我想如何处理它的想法并将其删除。

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

关于iphone - UIViewController 上的两个标题栏(UITableViewController 的 subview ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12848935/

相关文章:

ios - 带有附件下载 API 支持的一次性临时电子邮件

View 上带有 slider 和 2 个按钮的 iOS 应用程序

ios - 共享管理器的 Alamofire 固定

ios - 不调用 ObjC 类方法。 GDB玩游戏?

iphone - iOS 奇怪的委托(delegate)行为?

iphone - 如何创建我自己的 Web API/Web 服务

ios - iPhone 应用程序终止进程

iphone - 适用于 iPhone 应用程序的移动 OCR 引擎

iphone - 如何使用 Xcode 制作首次启动 iPhone App 的导览

ios - 使用AWSS3TransferManagerUploadRequest如何设置超时间隔?