Rectangle 27 3

Instead of hiding and showing the navigation bar, you can update the alpha for the navigation bar. It will animate smoothly during the transition. For the view controller with transparent nav bar, instead of modifying the nav bar, create a navbar (or just the back button and title etc.) manually in the second controller's view. We will then hide the navbar when transitioning from first view controller to the second one.

On your first controller's viewWillDisappear and on your second view controller's viewWillAppear:, set the navigation bar alpha to zero using self.navigationController.navigationBar.alpha = 0;. Since this is in animation block, this will make the navigation bar disappear during the push animation.

Set the alpha back to one in first controller's viewWillAppear and second controller viewWillDisappear.

ios - Transitioning between transparent navigation bar to translucent ...

ios uinavigationcontroller uinavigationbar
Rectangle 27 3

Instead of hiding and showing the navigation bar, you can update the alpha for the navigation bar. It will animate smoothly during the transition. For the view controller with transparent nav bar, instead of modifying the nav bar, create a navbar (or just the back button and title etc.) manually in the second controller's view. We will then hide the navbar when transitioning from first view controller to the second one.

On your first controller's viewWillDisappear and on your second view controller's viewWillAppear:, set the navigation bar alpha to zero using self.navigationController.navigationBar.alpha = 0;. Since this is in animation block, this will make the navigation bar disappear during the push animation.

Set the alpha back to one in first controller's viewWillAppear and second controller viewWillDisappear.

ios - Transitioning between transparent navigation bar to translucent ...

ios uinavigationcontroller uinavigationbar
Rectangle 27 3

Instead of hiding and showing the navigation bar, you can update the alpha for the navigation bar. It will animate smoothly during the transition. For the view controller with transparent nav bar, instead of modifying the nav bar, create a navbar (or just the back button and title etc.) manually in the second controller's view. We will then hide the navbar when transitioning from first view controller to the second one.

On your first controller's viewWillDisappear and on your second view controller's viewWillAppear:, set the navigation bar alpha to zero using self.navigationController.navigationBar.alpha = 0;. Since this is in animation block, this will make the navigation bar disappear during the push animation.

Set the alpha back to one in first controller's viewWillAppear and second controller viewWillDisappear.

ios - Transitioning between transparent navigation bar to translucent ...

ios uinavigationcontroller uinavigationbar
Rectangle 27 2

I was trying to do the same thing, but I wanted the back button to be in the navigation bar. (I actually needed a back button, that would do more than only going back, so I had to use the leftBarButtonItem property). I tried what AndrewS suggested, but in the navigation bar it wouldn't look the way it should, as the UIButton was kind of casted to a UIBarButtonItem.

But I found a way to work around this. I actually just put a UIView under the UIButton and set the customView for the UIBarButtonItem. Here is the code, if somebody needs it:

// initialize button and button view
UIButton *backButton = [UIButton buttonWithType:101];
UIView *backButtonView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, backButton.frame.size.width, backButton.frame.size.height)];

[backButton addTarget:self action:@selector(backButtonTouched:) forControlEvents:UIControlEventTouchUpInside];
[backButton setTitle:@"Back" forState:UIControlStateNormal];
[backButtonView addSubview:backButton];

// set buttonview as custom view for bar button item
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButtonView];
self.navigationItem.leftBarButtonItem = backButtonItem;

// push item to navigationbar items
[self.navigationController.navigationBar setItems:[NSArray arrayWithObject:backButtonItem]];

ios - Creating a left-arrow button (like UINavigationBar's "back" styl...

ios iphone cocoa-touch uinavigationbar uitoolbar
Rectangle 27 7

I had a similar case, however the view controller that I presented is wrapped in it's own navigation controller. So in that view controller when I need to determine whether or not to add the close button vs a back button, I just check the navigation controllers stack size. If the screen is presented, the stack size should be one (needs close button)... and if it is pushed using an existing navigation controller, then stack size will be larger than one (needs back button).

BOOL presented = [[self.navigationController viewControllers] count] == 1;

iphone - How to identify that an UIViewController is presented - Stack...

iphone ios objective-c uiviewcontroller modalviewcontroller
Rectangle 27 7

I had a similar case, however the view controller that I presented is wrapped in it's own navigation controller. So in that view controller when I need to determine whether or not to add the close button vs a back button, I just check the navigation controllers stack size. If the screen is presented, the stack size should be one (needs close button)... and if it is pushed using an existing navigation controller, then stack size will be larger than one (needs back button).

BOOL presented = [[self.navigationController viewControllers] count] == 1;

iphone - How to identify that an UIViewController is presented - Stack...

iphone ios objective-c uiviewcontroller modalviewcontroller
Rectangle 27 1

At least in Xcode 5, there is a simple and pretty good (not perfect) solution. In IB, drag a Bar Button Item off the Utilities pane and drop it on the left side of the Navigation Bar where the Back button would be. Set the label to "Back." You will have a functioning button that you can tie to your IBAction and close your viewController. I'm doing some work and then triggering an unwind segue and it works perfectly.

What isn't ideal is that this button does not get the < arrow and does not carry forward the previous VCs title, but I think this can be managed. For my purposes, I set the new Back button to be a "Done" button so it's purpose is clear.

You also end up with two Back buttons in the IB navigator, but it is easy enough to label it for clarity.

iphone - Setting action for back button in navigation controller - Sta...

iphone cocoa-touch uinavigationcontroller uibarbuttonitem
Rectangle 27 1

If I understand everything correctly I think I have a solution. I will ignore all other aspects of the navigation and just focus on the fact you want to go from VideoPreviewActivity to the MainActivity and adjust the fragment stack, and that this is being triggered from a done button (or something similar) but NOT the back button.

The simple way would be to use the activity result functions startActivityForResult which would allow you to use a onActivityResult function in the main activity to pass the information back. However you may potentially navigate to the VideoPreviewActivity via the VideoTrimActivity so you would have to pass this information back through two activities which would be a bit messy.

finish()
VideoPreviewActivity
Intent intent = new Intent(context, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra()//Add your return data here
startActivity(intent)

Instead of starting a new MainActivity this will return you to the previous one and finish all the activities sat above it in the task task.

MainActivity
@Override
protected void onNewIntent(Intent intent) {
    setIntent(intent);
}

Then in the onStart function you can check your intent to see if there is data in there returned from VideoPreview and remove the fragments you no longer need.

if (getIntent().hasExtra(YOUR_DATA)) {
        if (getSupportFragmentManager().getBackStackEntryCount() > 0)
            getSupportFragmentManager(). popBackStackImmediate("MESSAGE_TAG", 0);
}
ft.addToBackStack("MESSAGE_TAG")

This will clear all of the fragments with an addToBackStack in the transaction. The MessageFragment will start its lifecycle calls again and you can access the data from

getActivity().getIntent()
getSupportFragmentManager(). popBackStackImmediate("CAMERA_TAG", 0)
getSupportFragmentManager().popBackStack("CAMERA_TAG",FragmentManager.POP_BACK_STACK_INCLUSIVE);

No, you are right thats a problem with my example. You can do "CAMERA_TAG" INCLUSIVE or "MESSAGE_TAG" 0. I Will fix my answer.

It's probably better to use MESSAGE_TAG 0 as that will still work even if you add different fragments.

then i will use MESSAGE_TAG 0. thank you again for your effort. if you mark my question as useful i would be appreciated.

android - Return back to specific fragment of Activity-A from another ...

android android-fragments android-intent android-activity
Rectangle 27 0

I had a similar problem, and come out one library PButton. And the sample is the back navigation button like button, which can be used anywhere just like a customized button.

ios - Creating a left-arrow button (like UINavigationBar's "back" styl...

ios iphone cocoa-touch uinavigationbar uitoolbar
Rectangle 27 0

Instead of opening the URL with the UIApplication, you may instead want to consider implementing a UIWebView - download the data at the URL yourself, then display it in a web view and add that view (and a view controller) to a navigation controller. That way, you get the Back button and the system bar at the top, while still displaying the URL you want.

Want to show navigation bar while opening URL-iPhone - Stack Overflow

iphone navigation uinavigationbar
Rectangle 27 0

I found a workaround. I was trying to change the position of the back button title in the navigation bar. The title seems to be fixed in the lower left corner of it. So I changed the position of the whole navigation bar and adjusted its size accordingly so it would seem to be the same size in the view.

let xDisplacement: CGFloat = -25 // Adjust horizontal position
    let yDisplacement: CGFloat = 9 // Adjust vertical position
    let h = (self.viewIfLoaded?.frame.size.height)!/12 //Set your height in reference to the size of the view
    let w = (self.viewIfLoaded?.frame.size.height)!//Set your width in reference to the size of the view 
//Change placement adjusting size for change.
    self.navigationController?.navigationBar.frame = CGRect(x: xDisplacement, y: yDisplacement, width: w-xDisplacement, height: h-yDisplacement)

In my case the background is transparent so the adjusting doesn't really make a difference. Also I was trying to move the title left. I think that is the only situation where de adjusting is useful.

Anyway, just a workaround, but I hope it helps.

swift - Adjust vertical position of UIBarButtonItem title inside UIToo...

swift uibarbuttonitem uitoolbar