Coder Social home page Coder Social logo

urbanapps / uamodalpanel Goto Github PK

View Code? Open in Web Editor NEW
878.0 878.0 135.0 994 KB

An animated modal panel alternative for iOS

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

License: Other

Ruby 1.20% Objective-C 98.80%

uamodalpanel's People

Contributors

barrettj avatar bitdeli-chef avatar coneybeare avatar d4kr avatar ealeksandrov avatar funkadelic avatar kambala-decapitator avatar kennethmac2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uamodalpanel's Issues

UAModalPanel with UIViewController instead of UIView subclass

I tried UIModalPanel library and I really like it. My problem is that this library uses subclasses of UIView in all examples and then uses addSubview: . I would like to subclass a UIViewController which controls my view and then use: addChildViewcontroller and addSubview. The reason is that I need to manage application logic in that class and UIView would not be appropriate. Is that possible?

Smaller size with full screen background mask

This is a great plugin, thanks.
If I create a UAModalPanel with frame size 320x300, is there a way to still have the full screen background mask behind it?

I have played with the code a bit and can get a full screen mask by changing the self = [super initWithFrame:frame]; frame size, but then the content view and frame show half off the screen and not the correct size.

Any tips?

Thanks

Mixing of coordinate system at various points in code

I have been working a bit with UAModalPanel and have hit up against a few scenarios where things haven't been working as I expect them to. I have managed to trace these issues to what I think is a mixing up of the coordinate systems of different views at various points in the code.

Diving into the detail:

  1. In the roundedRectFrame: method of UAModalPanel, I think that all references to self.frame should in fact be to self.contentContainer.bounds, since self.frame is expressed in terms of the UAModalPanel's superview's coordinate system, which has no relation or connection to the frame of the rounded rectangle, which by definition is expressed in terms of self.contentContainer's coordinate system.

  2. In the show: method of UAModalPanel, I think that the line of code "self.contentContainer.center = self.center;" doesn't make sense, since self.center is expressed in terms of the UAModalPanel's superview's coordinate system, while self.contentContainer.center is expressed in terms of the UAModalPanel (self)'s coordinate system, and these will not necessarily be exactly overlapping (ie, where an (x,y) coordinate in one represents the same point on the screen as the same (x,y) coordinate in the other), nor should they have to be.

Additionally, it is unclear what the intended purpose of this line of code is anyway. In scenarios where self and self.contentContainer's frames are not exactly overlapping, this line breaks (as far as I can see) the correct display of the panel, even when only the show: method (as opposed to the showFromPoint: method) is called.

  1. In the showFromPoint: method of UAModalPanel, it seems incorrect to set self.contentContainer.center to the value of "point", as "point" will be expressed in terms of the UAModalPanel's superview's coordinate system (since that is the only coordinate system that the caller could be aware of; or, more specifically, the caller is not aware of self.contentContainer).

  2. If the thesis in (3) is correct, it would appear that the same problem also exists in the hide: and hideWithOnComplete: methods, as these both also use the value of "point" (here as "startEndPoint") to set the value of self.contentContainer.center.

iOS 6 compatibility errors

I'm not sure if you've tried out iOS6 and xCode 4.5, but this gives errors about the constraints. I think it's to do with the popping up animation as it doesn't appear from where it's set to appear from. The constraints system seems to have been changed in xCode 4.5
Here's an example of the errors:

2012-06-18 10:47:08.647 iSlide[2829:907] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x1e8c3c60 h=--& v=--& H:[UIView:0x1e8b3730(0)]>",
"<NSLayoutConstraint:0x1e8b2720 H:[UILabel:0x1e8b3010(42)]>",
"<NSLayoutConstraint:0x1e8b4b80 H:[UILabel:0x1e8b3010]-(NSSpace(20))-| (Names: '|':UIView:0x1e8b3730 )>",
"<NSLayoutConstraint:0x1e8b4b40 H:[UILabel:0x1e8b37c0]-(NSSpace(8))-[UILabel:0x1e8b3010]>",
"<NSLayoutConstraint:0x1e8b49a0 UILabel:0x1e8b37c0.centerX == UIView:0x1e8b3730.centerX>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1e8b2720 H:[UILabel:0x1e8b3010(42)]>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2012-06-18 10:47:08.666 iSlide[2829:907] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x1e8c3c60 h=--& v=--& H:[UIView:0x1e8b3730(0)]>",
"<NSLayoutConstraint:0x1e8b4fc0 H:[UILabel:0x1e8b34b0]-(NSSpace(20))-| (Names: '|':UIView:0x1e8b3730 )>",
"<NSLayoutConstraint:0x1e8b4f40 UILabel:0x1e8b34b0.leading == UILabel:0x1e8b30b0.leading>",
"<NSLayoutConstraint:0x1e8b4e40 UILabel:0x1e8b30b0.leading == UILabel:0x1e8b3280.leading>",
"<NSLayoutConstraint:0x1e8b4dc0 UILabel:0x1e8b3280.leading == UILabel:0x1e8b46f0.leading>",
"<NSLayoutConstraint:0x1e8b4c80 UILabel:0x1e8b46f0.leading == UILabel:0x1e8b3010.leading>",
"<NSLayoutConstraint:0x1e8b4b40 H:[UILabel:0x1e8b37c0]-(NSSpace(8))-[UILabel:0x1e8b3010]>",
"<NSLayoutConstraint:0x1e8b49a0 UILabel:0x1e8b37c0.centerX == UIView:0x1e8b3730.centerX>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1e8b4b40 H:[UILabel:0x1e8b37c0]-(NSSpace(8))-[UILabel:0x1e8b3010]>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2012-06-18 10:47:08.674 iSlide[2829:907] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x1e8c3c60 h=--& v=--& H:[UIView:0x1e8b3730(0)]>",
"<NSLayoutConstraint:0x1e8b4fc0 H:[UILabel:0x1e8b34b0]-(NSSpace(20))-| (Names: '|':UIView:0x1e8b3730 )>",
"<NSLayoutConstraint:0x1e8b4f00 H:[UILabel:0x1e8b44c0]-(NSSpace(8))-[UILabel:0x1e8b34b0]>",
"<NSLayoutConstraint:0x1e8b4c00 H:|-(NSSpace(20))-[UILabel:0x1e8b44c0] (Names: '|':UIView:0x1e8b3730 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1e8b4f00 H:[UILabel:0x1e8b44c0]-(NSSpace(8))-[UILabel:0x1e8b34b0]>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

issues with intiWithFrame:CGRectMake

Hi,

first of all great work.
Unfortunately I'm experiencing an error when not using initWithFrame:self.view.bounds but instead initWithFrame:CGRectMake(40,90,220,100).
The panel is somehow presented but unfortunately in 3 not connected parts. The Background is presented at the correct position, the roundect got an x,y offset of approx 60,80 and the content within gets another offset of about the same.

What's wrong ?

Cheers, Peter

iOS 4 Compatibility broken?

Just ran this nice little library on an iOS 4.3 device and noticed a crash:

In the actionButton method of UAModalPanel:
-[UIImage resizableImageWithCapInsets:]: unrecognized selector sent to instance

[UIImage resizableImageWithCapInsets] is iOS 5+ only.

specify size

Is there any way I can simply specify how large the panel should be?

I always want it to be centered. I want the light gray view to take over the entire view I"m adding the panel as a subview. But I always want the panel to be say 200x200 whether on iphone or ipad.

Is this possible?

Memory leak?

When I run your example project through Instruments/Leaks it shows me some leaks after the panel has been opened, closed, opened and closed again.
I'm just wondering if this is a leak in the code, or a bug in Instruments.
I'm using Xcode 4.5 beta so it's possibly a bug.

Have you tried running instruments on this?

Thanks

Delay

Hello,

I am trying to track down a delay. I am getting a delay of around 1.4seconds or so between willShowModalPanel and my layoutSubViews method in my uatitledmodalpanel inherited class.

Any help would be appreciated
m

Tag version

Hi,

it's possible to tag the current version so I can create a spec file for cocoapods?

Thx
Davide

closeButton appears under contentView in certain circumstances

The closeButton: and actionButton: methods of UAModalPanel both use insertSubview:aboveSubview: to add their respective views to self.contentContainer. The contentView: method on the other hand uses the more basic addSubview: method.

From what I can see, two improvements would make sense here:

  1. The insertSubview:aboveSubview: calls in closeButton: and actionButton: should say "aboveSubview:self.contentView" instead of "aboveSubview:self.roundedRectangle", since contentView must be above roundedRectangle for everything to look correct, and, currently (ie, without this change), in situations where the UAModalPanel instance's top and left padding values are small, contentView obscures closeButton due to closeButton being below contentView in the view hierarchy.

  2. As an additional enhancement, in the contentView: method, the addSubview: call should be replaced with the following call:

[self.contentContainer insertSubview:contentView aboveSubview:self.roundedRect];

This makes it more clear what is going on and doesn't require one to think about the implicit ordering behaviour that is made use of when calling addSubview:.

More instructions for ARC would be helpful

Specifically, in my ARC project, if I add a view to contentView, will UAModalPanel still take care of retaining and deallocating it when it doesnt need it? or if not how else do I do that?

Also, if I subclass UAModalPanel, does that subclass need to be compiled with the -fno-objc-arc flag? Or can I use ARC in the subclass?

Also, when i have an instance of UAModalPanel in my code, do I have to do anything special like retain and deallocate it, or will ARC take care of that for me just like any other class i use?

Fixed portrait position

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 ?

Can hide navigation bar?

All examples I saw, UAModalPanel hides the navigation bar, but when I have implemented in my project, the navigation bar doesn't hide. I use in TableViewController.

Rotation Support?

Can someone add Rotation support for this? I have no idea how to do that otherwise I'd do it myself ;)

Graphical glitch as sub view of tabbarcontroller.

I've added the panel as a sub view of my tabbarcontroller controller. When the app rotates, the grey background doesn't cover the navbar or the tabbar. When the rotation finishes it appears normal again. Any Ideas?

Add Size instead of Margins

I've setup my code to basically allow me to set the size of the panel and have it figure out the correct margins and resize accordingly based on rotation. If anyone wants to add this feel free to use my work ;) The code below is the setup I used for my custom UAModalPanel regarding size.

- (id)initWithFrame:(CGRect)frame withimage:(UIImage *)image {

    if ((self = [super initWithFrame:frame])) {

        [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(didRotate:)
                                                    name:@"UIDeviceOrientationDidChangeNotification" 
                                                  object:nil];

        float contentWidth = 250;
        float contentHeight = 250;

        float xCenter = (frame.size.width / 2);
        float yCenter = (frame.size.height / 2);

        float topEdge = 0;
        float bottomEdge = 0;
        float leftEdge = 0;
        float rightEdge = 0;


        if ([[[UIDevice currentDevice] model] isEqualToString:@"iPad"]) {

            contentWidth = 500;
            contentHeight = 500;
        } 

        MA_MobileAppDelegate *appDelegate = (MA_MobileAppDelegate *)[[UIApplication sharedApplication] delegate];

        UIInterfaceOrientation orientation = appDelegate.tabBarController.interfaceOrientation;

        switch (orientation) {

            case UIDeviceOrientationPortrait:

                NSLog(@"Initial right side up");

                topEdge = frame.size.height - (yCenter + (contentHeight / 2));
                bottomEdge = (yCenter - (contentHeight / 2));
                leftEdge = (xCenter - (contentWidth / 2));
                rightEdge = frame.size.width - (xCenter + (contentWidth / 2));

                break;

            case UIDeviceOrientationPortraitUpsideDown:

                NSLog(@"Initial upsideDown");

                topEdge = frame.size.height - (yCenter + (contentHeight / 2));
                bottomEdge = (yCenter - (contentHeight / 2));
                leftEdge = (xCenter - (contentWidth / 2));
                rightEdge = frame.size.width - (xCenter + (contentWidth / 2));

                break;

            case UIDeviceOrientationLandscapeRight:

                NSLog(@"Initial right");

                topEdge = frame.size.height - (yCenter + (contentHeight / 2));
                bottomEdge = (yCenter - (contentHeight / 2));
                leftEdge = (xCenter - (contentWidth / 2));
                rightEdge = frame.size.width - (xCenter + (contentWidth / 2));

                break;

            case UIDeviceOrientationLandscapeLeft:

                NSLog(@"Initial Left");

                topEdge = frame.size.height - (yCenter + (contentHeight / 2));
                bottomEdge = (yCenter - (contentHeight / 2));
                leftEdge = (xCenter - (contentWidth / 2));
                rightEdge = frame.size.width - (xCenter + (contentWidth / 2));

                break;

            default:
                break;
        }



        self.margin = UIEdgeInsetsMake(topEdge, leftEdge, bottomEdge, rightEdge);

        self.padding = UIEdgeInsetsMake(20.0, 20.0, 20.0, 20.0);

        self.borderColor = [UIColor whiteColor];

        self.borderWidth = 1.5f;

        self.cornerRadius = 4.0f;

        self.contentColor = [UIColor colorWithWhite:0.0 alpha:0.8];

        self.shouldBounce = YES;


        UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease];
        [imageView setImage:image];
        [imageView setContentMode:UIViewContentModeScaleAspectFit];

        view = imageView;

        [self.contentView addSubview:view];

    }   
    return self;
}

- (void) didRotate:(NSNotification *)notification { 

    MA_MobileAppDelegate *appDelegate = (MA_MobileAppDelegate *)[[UIApplication sharedApplication] delegate];

    UIInterfaceOrientation orientation = appDelegate.tabBarController.interfaceOrientation;

    if (currentOrientation != orientation) {

        float contentWidth = 250;
        float contentHeight = 250;

        frameWidth = self.contentContainer.frame.size.width;
        frameHeight = self.contentContainer.frame.size.height;

        float xCenter = (frameWidth / 2);
        float yCenter = (frameHeight / 2);

        float topEdge = 0;
        float bottomEdge = 0;
        float leftEdge = 0;
        float rightEdge = 0;

        if ([[[UIDevice currentDevice] model] isEqualToString:@"iPad"]) {

            contentWidth = 500;
            contentHeight = 500;
        } 

        switch (orientation) {

            case UIDeviceOrientationPortrait:

                topEdge = frameHeight - (yCenter + (contentHeight / 2));
                bottomEdge = (yCenter - (contentHeight / 2));
                leftEdge = (xCenter - (contentWidth / 2));
                rightEdge = frameWidth - (xCenter + (contentWidth / 2));

                currentOrientation = orientation;

                break;

            case UIDeviceOrientationPortraitUpsideDown:

                topEdge = frameHeight - (yCenter + (contentHeight / 2));
                bottomEdge = (yCenter - (contentHeight / 2));
                leftEdge = (xCenter - (contentWidth / 2));
                rightEdge = frameWidth - (xCenter + (contentWidth / 2));

                currentOrientation = orientation;


                break;

            case UIDeviceOrientationLandscapeRight:

                topEdge =  (yCenter - (contentHeight / 2));
                bottomEdge = frameHeight - (yCenter + (contentHeight / 2));
                leftEdge = (xCenter - (contentWidth / 2));
                rightEdge = frameWidth - (xCenter + (contentWidth / 2));

                currentOrientation = orientation;

                break;

            case UIDeviceOrientationLandscapeLeft:

                topEdge =  (yCenter - (contentHeight / 2));
                bottomEdge = frameHeight - (yCenter + (contentHeight / 2));
                leftEdge = (xCenter - (contentWidth / 2));
                rightEdge = frameWidth - (xCenter + (contentWidth / 2));

                currentOrientation = orientation;

                break;

            default:
                break;
        }

        self.margin = UIEdgeInsetsMake(topEdge, leftEdge, bottomEdge, rightEdge);

        [self setNeedsLayout];
    }

}

contentView is always (0,0,0,0) when constructing panel

Customizing the panel fails in most cases because you cannot read the size of the content area.

Workaround:

  1. after instantiating the panel (initWithFrame:), add it to the target view
  2. call [panel layoutSubviews]; to force it to calculate its TRUE sizes
  3. run the customization code

NB: this means you must not put your panel-contents-code into "initWithFrame:" - because during that method you have no way to get your sizes correct ... unless it's safe to call layoutSubviews inside the constructor?

(your example panel ignores sizes, so doesn't have this problem)

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.