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

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.

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:
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)
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;

Related

How to make transition from RootController to DetailController UITableview iphone sdk

I have a UITableView with some Cells.
I don't use NavigationController, so I'd like to use UIModalTransition to Switch from RootController, my TableViewcell, to my DetailView, but want to add a Navigation bar to attribute some actions, like Backbutton.
I don't want to use seguesTransition, I only used XIB File and any Storyboard.
I really don't know how to use the Modal Transition in TableView, anyone know how i can do it ?
Thanks.
have you tried
[self presentModalViewController:yourViewController animated:YES];
then you can set certain styles for transitions in it.
On the other view add a navigationbar and place a backbarbuttonitem and add an action to it to go back to your previous view.
Although why do you want to do it is unclear to me.
if you dont want a navigation controller on the first view, you can just set it to hidden.
self.navigationController.navigationBar.hidden = YES;
and then in the viewDidLoad of other view you can do the reverse i.e
self.navigationController.navigationBar.hidden = NO;
this is quite an easy way of achieving what you want with relatively less amount of code!!

How to decrease the UINavigation Bar size and how to separate the back button from navigation bar

I am developing one application.In that I need to decrease the UINavigationBar size, For that I use the below code.
CGFloat navBarHeight = 10.0f;
CGRect frame = CGRectMake(50.0f, 0.0f, 320.0f, navBarHeight);
[self.navigationController.navigationBar setFrame:frame];
But when I go to next page, that page Navigationbar also changed.But I need to change only one page. And I want to separate the back button and place before navigation bar.So for that i place one button before UINavigationBar.But I don't perform it action.
So please tell me how to do this one.
Thanks in advance...
What you need to be aware of is that the Navigation Controller manages an entire view hierarchy. When you have ViewControllerA, in which you alter the navigation bar of the navigation controller's height, and then push ViewControllerB onto that navigation controller's stack, you are effectively looking at the same navigation bar. You will need to change the height back to it's original in ViewControllerB.
I'm not sure what you mean by "Separate the back button and place before navigation bar". Do you have a picture or could you clarify the question?
UPDATE: Based on your comment, what you are trying to achieve is possible, but a bad idea. A UINavigationController's navigationBar spans the entire width of the screen. Regardless of the technical feasibility of shortening the width of this bar to show your button to the left of it, this arguably infringes on the HIG's, which require standard use of standard iOS features; i.e. the navigation bar should always span the width of the device in either orientation. If you are looking to replace the standard back button with a different button, that is possible by simply replacing the leftNavigationItem, i.e.
self.navigationItem.leftNavigationItem = <SomeUIBarButtonItem>;
You probably want to set hidesBackButton = YES, as well.
UPDATE 2: I tested this in a small Xcode project, and you can change the width of the navigation bar. It looks silly, but it's possible. However, if you use a nib and set the NavigationBar property on that nib, when you add your button to the view controller's view, you have to set the y value of the frame to a negative number to get it in line with the nav bar. Even still, setting text or target/actions on this button don't seem to work. The navigation bar might reserve that width for itself. Removing the nav bar setting from the nib and trying again still doesn't do it. The presence of the navigation bar (or, really, the navigation controller, most likely), seems to prevent anything else from receiving touch events in that area.
You need to change size of UINavigation bar in every page.
Regarding return button I used this solution:
-(void)returnButton:(id)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
}

Full screen UIImage view

I have an application with a navigation bar and a tab bar. A user can navigate to a view which displays images in a scroll view. I'd like to have the same behavior as the iPhone photo app: Nav bar at the top, tool bar at the bottom, which will hide or show based upon a tap.
I'm moving my view to the window object in order to achieve full screen mode. This works fine:
myView = [self.view retain];
self.view = nil;
[window addSubview:myView];
But when I want to redisplay the Nav & tool bar, I run into a problem. The bars show fine, but the view is empty, and I can't seem to add any content to the view:
[myView removeFromSuperview];
self.view = myView;
I got a lot of good info from this post
but can't quite get the right combination.
By simply setting the controller's view, you aren't adding it as a subview to anything else, so it will never appear.
Moving views around like this can get a little tricky. I recommend that you not move the view from one to the other, but instead have two UIViews. Add second UIView to the window's subview and set it to hidden=YES initially. When you want to show it, set the image for the UIImageView, and then set the hidden property to NO.
what's wrong with just using setNavigationBarHidden: animated: and setToolbarHidden:animated:?

How to prevent view resizing/transform when UINavigationBar hides/shows

I have an application with a tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.
How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.
Had this issue and fixed it with a class that inherited from UINavigationController
-(void)viewWillAppear:(BOOL)animated
{
self.navigationBar.translucent = YES;
}
Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];
this seemed to do the trick for me!
I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder
I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)

How to hide an iPhone Tab Bar?

I have a small multiview app. It consists of a UITabBarController with a nav controller in each tab. What I want is to show a UIImageView when a user shakes the device. After I've implemented the loading of the UIImageView, I faced a problem-the image was only 2/3 of the screen because of the tab and nav bars. I managed to hide the nav bar but I'm still stuck with the tab bar. I tried many solutions such as [tabBar setHidden: YES]; but I get errors "tabBar undeclared", although I've imported the AppDelegate, where the tabBar was defined.
Thanks in advance!
Try setting
myViewController.hidesBottomBarWhenPushed = YES;
when you create your UIImageView. When you push it on to the view stack the UITabBar will hide automatically, and it will be restored automatically when you pop or dismiss the controller. No need for the application delegate.
If you want to show a full screen view, it is best to use a modal view controller. This way you do have to worry about hiding/showing navigation items. Take a look at:
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html
to get started.