In iOS 7 Apple add new default navigation behavior.
You can swipe from left border of the screen to go back on navigation stack.
But in my test project, this behavior seems doesn't work. I've check it for many times and tried the following blog
http://keighl.com/post/ios7-interactive-pop-gesture-custom-back-button/
UPDATE
Actually it works, but I have to swipe from the very left of the screen, so I made a mistake, can we optimize it?
Add this code in your Appdelegate.m file and pop gesture will work in your whole application. Also add the UIGestureRecognizerDelegate in your Appdelegate.h file.
self.navigationController.interactivePopGestureRecognizer.delegate = self;
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
Swipe from the very left end of the screen, only then the pop gesture will work
You haven't write any code in your project and
for navigation behaviour you must add UINavigationController to your project.
please put proper link or proper code here.
Were you using the simulator? its harder to do there than on real devices.
I wouldn't recommend changing how this gesture works, it should be uniform between apps to be useful.
Related
I'm developing an iOS 10 app using NavigationController and Storyboards. I'm having a difficult time to figure out whats going on with a strange - as I'm calling it - bug:
When I navigate to a new ViewController, it show's nicely, but when the app unwind a segue, the top view controller doesn't go all the way to the right, instead, it left's about 50 points on screen, and then suddenly it goes away...
I'm putting a image that illustrates what I'm talking about...
PS: both ViewControllers uses UIImageView as background...
Thanks a lot!
Please share the code where you are setting the fame for the view(s). It could possibly be an offset that is being added. Though, you do mention that it does go away suddenly, so it could be something else.
I have a UITableViewController which contains cells of different languages. When the user taps a cell, they are taken to a UIPageViewController which shows the appropriate leaflet in that language. That part is working well.
I have implemented the use of the following code to make the UINavigationBar hidden and to appear on a tap:
self.navigationController.navigationBar.hidden = YES;
self.navigationController.hidesBarsOnTap = true;
I have that code in my viewDidLoad. I don't have any gesture recognisers, but both on the Simulator and on the device, to get the UINavigationBar to appear, I have to tap the screen twice. Why do I have to tap twice?
If I do the same on a UITableViewController, I only have to tap once, so it seems something specific about this UIPageViewController and I can't quite figure out what.
I've looked around and I can't seem to find anyone with anything similar.
On guidance on this would be appreciated.
Try this :
[self.navigationController setNavigationBarHidden:YES animated:YES];
If that does not work, can you post the code for your methods relevent to this issue?
Could probably help more with more info.
After upgrading my project to iOS7
when I do a BACK Button and the UINavigationController goes back to the previous page, an ImageView on the top of the screen shifts down.
I use IB to do my layouts. These are my Simulated Metrics:
I have AutoLayout off. Any ideas on what the issue might be? I wasnt sure if anyone wants to see specific code and I didnt want to clutter up the question with too much code.
Updates: Based on the comment questions, I wanted to make these updates:
In no place in the application .h or .m file do I make any changes to the imageview's sizes or location.
In both the viewDidLoad and viewDidAppear I call a user-defined method called recalculateAll but their is no reference at all to any imageview sizes. Just for trying it out I commented out the entire section and ran the code and it still jumps down.
In my init I do programatically set some imageviews (you see the #132 in what appears to be a bubble) using their x and y's.
Here is a typical navigation I use for moving from the view controller to the tableviewcontroller:
GetTimeOffByType *showTimeOffReport = [[GetTimeOffByType alloc] initWithNibName:#"GetTimeOffByType" bundle:nil];
showTimeOffReport.timeOffType = #"Vacation";
[self.navigationController pushViewController:showTimeOffReport animated:YES];
These are all .xib files, no storyboarding at all. Its basically a view controller which has an embedded UINavigationController with 6 buttons. Each time a button is pressed it pushes a UITableViewController passing different parameters and showing different data. The transition I am using to get back to the original UIViewController is simply the iOS generated BACK button (so no code to show for that)
Update#2 Hopefully this will help someone solve this wierd behavior. So if I were to click on the table view cell on showTimeOffReport to get the cell detail and then using BACK navigate all the way back it doesnt jump down.
Update#3 Ok this is something I just discovered : The issue of jumping down or not is related to the translucency of the UINavigationBar. If you have a Translucent = YES it will start from the top of the window. If you have a translucent = NO it will start from the bottom of the UINavigationBar.
You might try setting the new property on UIViewController edgesForExtendedLayout to UIRectEdgeNone.
Here is a good resource that explains more about how view layouts changed in iOS 7.
See Apple Documentation
If you plan to be backwards compatible you will probably need to do some runtime checks and adjust positioning if the device is not running iOS 7.
This might help you..You can try adding UIViewControllerBasedStatusBarAppearance key and set it's value NO in your info.plist
UIViewControllerBasedStatusBarAppearance = NO
for my App I need to recognize a swipe gesture on a toolbar to change the items on the toolbar. So I can scroll through the toolbar.
I want to develop for iOS 5.0 or higher with XCode 4.3
I only found out how to change viewController by using swipeGestures.
Can you help me?
-(void)swipeDidHappen:(UISwipeGestureRecognizer*)swipe {
[self setToolbarItems:secondArray animated:YES];
}
Should fade out/in some new items great. Note that the toolbar must be the one supplied by UINavigationController. To hook it up, create one in code, and use [[self toolbar]addGestureRecognizer:gesture];. secondArray is an array of UIBarButtonItems, which must be made programmatically (as far as I know, you cannot storyboard an array, nor should you).
Short version:
I'm alloc/init/retaining a new UIViewController in one UIViewControllers viewDidLoad method, adding the new View to self.view. This usually works, but it seems to mess up orientation change handling of my iPad app.
Longer version:
I'm building a fairly complex iPad application, involving a lot of views and viewcontrollers. After running into some difficulties adjusting to the device orientation, I made a simple XCode project to figure out what the problem is.
Firstly, I have read the Apple Docs on this subject (a small document called "Why won't my UIViewController rotate with the device?"), and while I do believe it has something to do with one of the reasons listed there, I'm not really sure how to fix it.
In my test project I have an appDelegate, a rootViewController, and a UISplitViewController with two custom viewControllers. I use a button on the rootViewController to switch to the splitViewController, and from there I can use a button to switch back to the rootViewController. So far everything is great, i.e. all views adjust to the device orientation.
However, in the right viewController of the splitViewController, I use the viewDidLoad method to initialize some other viewControllers, and add their views to its own view:
self.newViewController = [[UIViewController new] autorelease];
[newViewController.view setBackgroundColor:[UIColor yellowColor]];
[self.view addSubview:newViewController.view];
This is where things go wrong. Somehow, after adding this view, adjusting to device orientation is messy. On startup everything is fine, after I switch to the splitViewController everything is still fine, but as soon as I switch back to the rootViewController it's all over. I have tried (almost) everything regarding retaining and releasing the viewcontroller, but nothing seems to fix it.
As you can see from the code above, I have declared the newViewController as a property, but the same happens if I don't.
Shouldn't I be adding a ViewController's view to my own view at all? That would really mess up my project, as I have a lot of viewControllers doing all sorts of things.
Any help on this would be greatly appreciated...
I had the same problem, seams resolved by removing from the parent view the "autoresize subview" option in IB.
Select the view a then: Inspector -> Attributes (first tab) -> drawing.
What I think is happening is that your new viewcontroller is getting the autorotation calls and probably not handling them. Meanwhile your old viewcontrollers and its views won't get the autorotation calls and will be stuck in whatever orientation they were in.
I can't tell, but I think what you want to do is to make a UIView and add it to your old viewcontroller, instead of making a UIVIewController and adding its view.