将右侧的 barbuttonitem 添加到导航控制器 iphone sdk 后,视图向上移动

发布于 2024-09-04 06:24:25 字数 659 浏览 2 评论 0原文

在我的应用程序中,导航控制器下方的视图向上移动,并且在导航栏下方可见,因为在以编程方式将 barbuttonitem 添加到导航控制器(我通过 xib 添加到视图)后,它变得透明。

这就是我添加它的方式:

UIBarButtonItem *comment = [[UIBarButtonItem alloc]
                            initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
                            target:self
                            action:@selector(buttonPressed)];

self.navigationItem.rightBarButtonItem = comment;

编辑:

好的,我很清楚发生这种情况,因为对于除一个之外的所有不同类型的自定义单元格,我将详细视图的 xib 文件推送到点击单元格的导航控制器,但对于这唯一一个,我以编程方式创建了一个视图控制器并推送它。因此,只要我不在详细视图中点击并打开此单元格,一切都会正常工作,但是在我打开此单元格的详细视图(始终打开良好)后,其他单元格的详细视图会发生变化。

有人可以解决这个问题吗?

提前致谢。

In my application, the view below navigation controller moves up and is visible below the navigation bar as it's becoming transperant after adding a barbuttonitem programmatically to the navigation controller which I'm adding to view through an xib.

This' the way I'm adding it:

UIBarButtonItem *comment = [[UIBarButtonItem alloc]
                            initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
                            target:self
                            action:@selector(buttonPressed)];

self.navigationItem.rightBarButtonItem = comment;

EDIT:

Ok, I quite came to know that this' happening because for all my custom cells of different type except one, I'm pushing xib files of detailedviews to navigation controller for tapped cells, but for this only one, I've created a view controller programmatically and pushing it. So as long as I don't tap and open this cell in detailview, everything works fine, but after I open this cell's detailview(which always opens fine), other cells detailviews shift.

Can anybody please address this issue?

Thanx in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浮华 2024-09-11 06:24:25

检查所有视图的框架并为所有子视图设置不同的颜色进行测试。您会很容易找到问题。或者贴出更详细的代码。

Check all view's frame and for testing set different color for all subviews.You will find out the problem easily. or post more detailed code.

[旋木] 2024-09-11 06:24:25

viewControllers 视图大小的差异:

  1. 如果您通过 .XIB 创建它,那么您将在其中看到状态栏。意味着您的视图大小比窗口小 20 像素。 (320 * 460)

  2. 如果您以编程方式创建它,则不会有状态栏。意味着尺寸将为 320*480。

这样视图框架就不同了...

所以将视图的大小设置为320*460并尝试...

Difference in size of viewControllers view:

  1. If you are creating it through .XIB, then you will be having status bar in it. means your view size is 20 pixels lesser than that of the window. (320 * 460)

  2. If you are creating it programmatically, then there will not be a status bar. Means size will be 320*480.

In this way view frame differs...

So set the size of view to 320*460 and try out...

爱要勇敢去追 2024-09-11 06:24:25

好吧,经过一番努力,我发现导致问题的原因是,由于我使用 Three20 库来显示类似 facebook 的照片,其中的 TTPhotoviewcontorller 将导航控制器的导航栏的栏样式更改为 UIBarStyleBlackTranslucent ,您需要做的是将栏样式属性重置为 UIBarStyleDefault。您应该尝试调用

self.navigationController.navigationBar.bar = UIBarStyleDefault;

Ok, after lot of struggling, I figured it out that what causes the problem is that since I'm using Three20 library to show facebook-like photos, the TTPhotoviewcontorller in it changes the bar style of the navigation bar of your navigation controller to UIBarStyleBlackTranslucent, and what you need to do is to reset the bar style property to UIBarStyleDefault. You should try to call

self.navigationController.navigationBar.bar = UIBarStyleDefault;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文