UrbanApps / UAModalPanel

An animated modal panel alternative for iOS

Home Page:http://code.coneybeare.net/uamodalpanel-an-open-source-modal-panel-alter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fixed portrait position

mal3k opened this issue · comments

Hi, my app support portrait and landscape orientations, but when using the UAModalPanel view, I need that (UAModalPanel) to be fixed to portrait orientation. I don't find a suitable property in the class UIModalPanel.h to do so. Can you provide a workaround to fix that ?

Rotation is handled by you. If you want to do this the easiest way, show the panel in the applications window, not the view controller's view.

Hi, ok so now I have two small issues, when I add the panel to the window, panel's subview appear in the background not as subviews, and also the panel frame is not drawn properly because I want it to fill all the screen. Here is my relevant code if you can help me:

    UIImage *image = [UIImage imageNamed:@"startscreen.jpg"];
    modalPanel = [[UAModalPanel alloc] initWithFrame:CGRectMake(0, 20, image.size.width, image.size.height)];
    modalPanel.margin = UIEdgeInsetsMake(0, 0, 0, 0);

    splashImageView = [[UIImageView alloc] initWithImage:image];
    splashImageView.frame = CGRectMake(0, 20, image.size.width, image.size.height);
    [modalPanel addSubview:splashImageView];//this doesn't show the image view as a subview
    [[[UIApplication sharedApplication].delegate window]addSubview:modalPanel];//Add to the app window

Your modal panel should have the same frame as the window. Your splashImageView should be added to the modalPanel.contentView. If you still can't get it this way, simply prevent auto-rotation on your view controller until after the panel has been dismissed.

Yes, I tried to add it as subview of the contentView, but it still appear behind the modalPanel, that's weird:

UIImage *image = [UIImage imageNamed:@"startscreen.jpg"];
modalPanel = [[UAModalPanel alloc] initWithFrame:CGRectMake(0, 20, image.size.width, image.size.height)];
modalPanel.margin = UIEdgeInsetsMake(0, 0, 0, 0);

splashImageView = [[UIImageView alloc] initWithImage:image];
splashImageView.frame = CGRectMake(0, 20, image.size.width, image.size.height);
[modalPanel.contentView addSubview:splashImageView];//this still doesn't show the image view as a subview
[[[UIApplication sharedApplication].delegate window]addSubview:modalPanel];//Add to the app window

upload a screenshot of what you are seeing?

I can see the splash image view under the modal panel view, it should be above and shown as subview, I am missing something surely

Check the example project. There is a clear sample of loading an image there. I would use that as your starting point to see where and how your code differs.

Here is the example code:

    UIImageView *iv = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease];
    [iv setImage:[UIImage imageNamed:@"UrbanApps.png"]];
    [iv setContentMode:UIViewContentModeScaleAspectFit];
   //get random view and assign it to a variable "v"
    [self.contentView addSubview:v];

Here is my updated code:

    UIImage *image = [UIImage imageNamed:@"startscreen.jpg"];
    modalPanel = [[UAModalPanel alloc] initWithFrame:CGRectMake(0, 20, image.size.width, image.size.height)];
    modalPanel.margin = UIEdgeInsetsMake(0, 0, 0, 0);

    splashImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
    [splashImageView setImage:image];
    [splashImageView setContentMode:UIViewContentModeScaleAspectFit];
    [modalPanel.contentView addSubview:splashImageView];//this still doesn't show the image view as a subview
    [[[UIApplication sharedApplication].delegate window]addSubview:modalPanel];//Add to the app window

Still getting exactly the same issue

how are you showing the panel?

Hi @coneybeare I have fixed the issue thanks to your help, actually I was adding the background image as the UIViewController subview in the code, so I removed that and now all is ok. Thanks.