开发者

view shifts up after adding right barbuttonitem to navigation controller iphone sdk

开发者 https://www.devze.com 2023-01-02 10:59 出处:网络
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 c

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 s开发者_运维百科hift.

Can anybody please address this issue?

Thanx in advance.


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.


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...


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;

0

精彩评论

暂无评论...
验证码 换一张
取 消