Git Product home page Git Product logo

tdsemimodal's Introduction

TDSemiModal

Include like this:

#import "TDSemiModal.h"

In order to show up your own modal view, just do this:

[self presentSemiModalViewController:newview];

And to hide:

[self dismissSemiModalViewController:newview];

A semi transparent 'cover' will be automatically put in to stop the user from interacting with the UI behind, so I recommend you set the background on your view to completely transparent.

Obviously you can create whatever semi-modal view you want, but a datepicker must be one of the most common usages, so I knocked up a class for that too.

DatePicker

This project also contains a datepicker view based off the TDSemiModal class.

The datepicker is quite simple to use - just create and display as before:

#import "TDDatePickerController.h"
TDDatePickerController* datePickerView = [[TDDatePickerController alloc]
                              initWithNibName:@"TDDatePickerController"
                              bundle:nil];
datePickerView.delegate = self;
[self presentSemiModalViewController:datePickerView];

Then you just need to catch the following actions in your delegate when the date is actually selected:

-(void)datePickerSetDate:(TDDatePickerController*)viewController;
-(void)datePickerClearDate:(TDDatePickerController*)viewController;
-(void)datePickerCancel:(TDDatePickerController*)viewController;

tdsemimodal's People

Contributors

ishaq avatar reednj avatar vbergae 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

tdsemimodal's Issues

dismissSemiModalViewController breaks KIF Tests

I am currently using KIF for automated UI testing. My app uses TDSemiModal for displaying a date picker.

However, when my KIF tests presents and removes a TDSemiModal, the KIF test hangs and eventually times out with a failure. Digging into the KIF code, I learned that KIF only tolerates animations that last for 0.5 seconds [1].

The problem is that when dismissing the semi modal view controller, the animation delay is set to 0.7 seconds [2]. To work around this issue, I added the following code to UIViewController+TDSemiModalExtension.m:

-(void) dismissSemiModalViewController:(TDSemiModalViewController*)vc {
    double animationDelay = 0.7;
    #if RUN_KIF_TESTS
        animationDelay = 0.3;
    #endif

        // ...
}

I have opened an issue with KIF about modifying the animation delay, but that does not solve the current problem for the dismissSemiModalViewController method.

I believe that the best solution to this issue is for KIF to fix its code, and users of both codebases to adopt the workaround I noted above. However, adding the above code to the TDSemiModal code is trivial and harmless thanks to the RUN_KIF_TESTS flag.

[1] See KIF / Classes / KIFTestStep.m:282
[2] See UIViewController+TDSemiModalExtension.m

TDSemiModalViewController.m

in -(void)viewDidLoad

self.coverView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];

Static analyzer complains about a potential leak. It may be solved with:

self.coverView = [[[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame] autorelease];

in dealloc it must be like this?

- (void)dealloc {
    //self.coverView = nil;
    [coverView release];
    [super dealloc];
}

Landscape Mode

I found that using the code below for determining the orientation works better. In our app we force landscape mode - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation inside a normal modal view and limiting with. With the previous way, the TDSemiModal thought it was still in portrait.

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

how to receive rotation calls?

Is there a way for the view controller presented by this to receive event calls like willRotateToInterfaceOrientation, didRotateFromInterfaceOrientation?

Please add semantic version tags

I’ve recently added TDSemiModal to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, TDSemiModal doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:

$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags

Memory leak

In -[TDSemiModalViewController viewDidLoad]

self.coverView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];

Adding Cover View and modal view on rootview controller distorts and places the picker view out of the window

Screen Shot 2013-01-14 at 10 35 05 AM

Modal view and root view is placed on top of the rootview . In some application like mine where the root view moves sometimes outside the window . The picker view produces some weird results.

UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
[mainWindow addSubview:coverView];
 [mainWindow addSubview:modalView];

adding that in - (void) presentSemiModalViewController:(TDSemiModalViewController*)vc ;
Solves this problem because the modal view is always shown on top of the window.

Screenshot or animated gif?

I just came across your library while trying to find a framework for implementing modals. However, I don't see a screenshot, animated gif, or video of what your library does. Can you please add a screenshot so that I can see if it will be something that I want to integrate?

Support for presenting in table view

Hi,

First of all thanks for your control it's amazing. I've been trying to add it to a project inside a table view but it has a weird offset. Even when you scroll the modal scrolls with you. I'm attaching an screenshot.

Sreenshot
Screeshot

Slow to open modal

Hello,

Thanks for a great library.
I am having only one problem. It takes about 1-2 seconds to open the modal.
Is there a way to speed it up?

TDDatePicker Locale

Hi,
currently the date picker locale is set to US (in the TDDatePickerController.xib file). It must be more correct to use the current device locale.

It can be accomplished in the .xib file or setting to nil the locale property of the Date picker.

I think everyone will appreciate it.

Thank you

Fail to call presentSemiModalViewController again soon after click Cancel on the TDDatePicker

Steps to reproduce the bug

Click on the UI which Activate
[self presentSemiModalViewController:datePickerView];

The normal TDPicker will show up

Click on cancel button which calls
[self dismissSemiModalViewController:datePickerView];

While the UI is dismissing(fading) quickly click on the UI which Activate the Picker again. the picker won't show if pressed before the fading process is completed

Note: I share the same Picker instance

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.