GithubHelp home page GithubHelp logo

Comments (12)

hfossli avatar hfossli commented on June 5, 2024

Thanks for reporting!

I will answer you in about 5 hours. I have some meetings I need to attend to first.

How did you add the AGWindowView and how did you time it in regards of the navigation controller

from agwindowview.

Fykec avatar Fykec commented on June 5, 2024

I add it by below code:

    AGWindowView *rootView = [[[AGWindowView alloc] init] autorelease];
    rootView.supportedInterfaceOrientations = UIInterfaceOrientationMaskAllButUpsideDown;
    [rootView addSubview:myView];

I don't clear understand the "how did you time it in regards of the navigation controller", but i pop the controller use below code, use system default animation time, and not hide the navigation bar

    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller];
    nav.navigationBarHidden = h;
    nav.modalPresentationStyle = UIModalPresentationFormSheet;
    nav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [_viewController presentModalViewController:nav animated:YES];
    [nav release];

I also try to change the code in didMoveToWindow to

- (void)didMoveToWindow
{
    [super didMoveToWindow];
    if(self.window == nil)
    {
        self.onDidMoveOutOfWindow ? self.onDidMoveOutOfWindow() : nil;
        [_activeWindowViews removeObject:self];
    }
    else
    {
        self.onDidMoveToWindow ? self.onDidMoveToWindow() : nil;
        [_activeWindowViews addObject:self];
        [self performSelector:@selector(rotateAccordingToStatusBarOrientationAndSupportedOrientations) withObject:nil afterDelay:1.0f];
//        [self rotateAccordingToStatusBarOrientationAndSupportedOrientations];
    }
}

It also can work, but I think the code update layout code no need

from agwindowview.

hfossli avatar hfossli commented on June 5, 2024

Thanks for adding more details.

  1. You display some custom view using AGWindowView
  2. You present some navigation controller using -[UIViewController presentModalViewController:animated:]
  3. You rotate 90 degress
  4. You pop the navigation controller
  5. Problem is visible

Is this is a correct understanding?

The problem as I understand it is that the AGWindowView is not placed correctly after step 1 to 4. Is that correct? OR is the problem that the rootviewcontroller is positioned wrongly? Can you please attach a screenshot? Please describe the problem / symptoms more in details.

Note:
It is necessary to call -[AGWindowView rotateAccordingToStatusBarOrientationAndSupportedOrientations] after adding it to UIWindow (e.g. didMoveToWindow) since it ensures the position and rotation is correct.

from agwindowview.

Fykec avatar Fykec commented on June 5, 2024

The Problem is occurred on step 4, step 4 will the trigger the AGWindowView move to the keywindow,
The Screen Shot:
Screen Shot 2013-04-10 at 10 38 07 AM

from agwindowview.

hfossli avatar hfossli commented on June 5, 2024

On the image you've posted it seems like something is misplaced with origin {90, 90} not {80, 80} as you mentioned, but that's minor details.

I also assume the white view is the AGWindowView, is that correct?
I assume the black view is a subview of AGWindowView, is that correct?

If you pause the console and write this in the debugger
po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]
can you please paste the output?

from agwindowview.

Fykec avatar Fykec commented on June 5, 2024

I also assume the white view is the AGWindowView, is that correct? YES
I assume the black view is a subview of AGWindowView, is that correct? YES

and i make a Demo https://www.box.com/s/8pd953j7lm1d4ts1uxpz for you

from agwindowview.

hfossli avatar hfossli commented on June 5, 2024

Thank you for creating that demo-application. That was most helpfull!

I am sorry to say you are not using AGWindowView as intended. I have now implemented some exception for this case. The problem is that you set AGWindowView to be the first UIView on UIWindow. UIWindow already handles rotations on the first UIView. I've created some samples in a demo-project you can look at (added to repo).

To fix your demo I did like this

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.

        UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [button setTitle:@"Pop" forState:UIControlStateNormal];
        [button addTarget:self action:@selector(onPopUpButton:) forControlEvents:UIControlEventTouchUpInside];
        [button setFrame:CGRectMake(100, 100, 100, 50)];

        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [view addSubview:button];
        self.view = view;
    }

    - (void)onPopUpButton:(id)sender
    {
        UIViewController *controller = [[UIViewController alloc] init];
        controller.view.backgroundColor = [UIColor redColor];

        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller];
        nav.navigationBar.topItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onPopUpDismiss:)];

        AGWindowView *windowView = [[AGWindowView alloc] initAndAddToKeyWindow];
        windowView.controller = nav;
        [windowView addSubviewAndFillBounds:nav.view withSlideUpAnimationOnDone:^{

        }];

        self.popUpNav = nav;
    }

    - (void)onPopUpDismiss:(id)sender
    {
        if (self.popUpNav)
        {
            AGWindowView *windowView = [AGWindowView activeWindowViewForController:self.popUpNav];
            [windowView slideDownSubviewsAndRemoveFromSuperview:^{

            }];
        }
    }

from agwindowview.

Fykec avatar Fykec commented on June 5, 2024

Ok, as you say, I can use a normal UIView as the UIWindow's first view, and window can handle rotation corretly? Before I use the UINavigationController's view as the first view, because I find some bug and mistake think it has relationship with UIView as UIWindow's subview, then i choose AGWindowView to replace .

so this no need I can switch back to UIView?

from agwindowview.

hfossli avatar hfossli commented on June 5, 2024

Yes. AGWindowView is mostly meant for overviews and fullscreen experience on top of standard UI. So AGWindowView should never be first subview on window.

You should use standard UIView as first subview.

from agwindowview.

hfossli avatar hfossli commented on June 5, 2024

I've updated the readme with some examples of when to use it :)

from agwindowview.

Fykec avatar Fykec commented on June 5, 2024

Thanks very much!

from agwindowview.

hfossli avatar hfossli commented on June 5, 2024

No problem ! :)

from agwindowview.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.