Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog doesn't appear (XCode 7.3) #18

Closed
m-etka opened this issue Apr 22, 2016 · 25 comments
Closed

Dialog doesn't appear (XCode 7.3) #18

m-etka opened this issue Apr 22, 2016 · 25 comments
Labels

Comments

@m-etka
Copy link

m-etka commented Apr 22, 2016

Dialog doesn't appear on my project.

Dialog view's frame seems to be correct:
(0.0, 0.0, 320.0, 568.0)

Also I tried to bring subview front by adding this line in the func show: method:
UIApplication.sharedApplication().windows.first!.bringSubviewToFront(self)

I'm using a navigation view controller under a tab bar controller. When debugging nothing seems to be wrong. I think it's only a visibility problem.

Any idea?

@mickaelmonsieur
Copy link

I have the same problem with XCode 7.3.1.
It makes it unusable ....

@lfarah
Copy link
Collaborator

lfarah commented Jul 19, 2016

Hey @mickaelmonsieur and @m-etka . I'm the new admin of this repo. Can you give me an example project of this problem?
Everything works here
screen shot 2016-07-19 at 3 56 04 pm

@lfarah
Copy link
Collaborator

lfarah commented Jul 19, 2016

@riazurcse said:
Hello Dear,
I am using storyboard. If i set entry point using storyboard then dialog working fine. When i set rootViewController programmatically in AppDelegate, DatePickerDialog not working anymore.

window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.makeKeyAndVisible()

storyboard = UIStoryboard(name: "Main", bundle: nil)

let homeViewController = self.storyboard?.instantiateViewControllerWithIdentifier("HomeView") as? HomeViewController
let userTypeController = self.storyboard?.instantiateViewControllerWithIdentifier("UserTypeView") as? UserTypeController

if self.window != nil {

    let userDataExist = CommonUserFunction.isUserDataExist() as Bool

    if userDataExist == true {

        let navigationController:UINavigationController = storyboard!.instantiateInitialViewController() as! UINavigationController
        navigationController.viewControllers = [homeViewController!]

        self.window!.rootViewController = navigationController
    }
    else{

        let navigationController:UINavigationController = storyboard!.instantiateInitialViewController() as! UINavigationController
        navigationController.viewControllers = [userTypeController!]

        self.window!.rootViewController = navigationController
    }
}

please Help...Thanks in advance...

@lfarah lfarah added the bug label Jul 19, 2016
@mickaelmonsieur
Copy link

Hi @lfarah
My problem is that I want to put the 'touch up inside' on the UITextField and not on a UIButton. And in this case it does not work...

@lfarah
Copy link
Collaborator

lfarah commented Jul 19, 2016

@mickaelmonsieur I got it to work using the UITextFieldDelegate:

    func textFieldDidBeginEditing(textField: UITextField)

The problem is that once you show it once, it won't show for the next time. Related to #27 I believe

@lfarah
Copy link
Collaborator

lfarah commented Jul 19, 2016

Alright, now it works completely:

    func textFieldDidBeginEditing(textField: UITextField) {
        let dialog = DatePickerDialog()

//        textField.resignFirstResponder()
        dialog.show("DatePickerDialog", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", datePickerMode: .Time) {
            (date) -> Void in
            if date != nil {
                let calendar = NSCalendar.currentCalendar()
                let comp = calendar.components([.Hour, .Minute], fromDate: date!)
                let hour = comp.hour
                let minute = comp.minute

                self.textField.text = "\(hour):\(minute)"
            } else {
                self.textField.text = ""
            }
        }

    }

We have a problem on the close() method that doesn't completely restarts the DatePicker

@lfarah
Copy link
Collaborator

lfarah commented Jul 19, 2016

Hey guys, I launched a new version (9830aa0) 1.1.2 and these problems are fixed.
Please let me know if it worked for you guys 😉

@lfarah lfarah closed this as completed Jul 19, 2016
@mickaelmonsieur
Copy link

xcode 7.3.1 : "if date != nil {" ---> Value of type 'NSDate' can never be nil, comparison isn't allowed

@mickaelmonsieur
Copy link

and the dialog will not open in my project, and in your demo either. (Only the button!)

@lfarah
Copy link
Collaborator

lfarah commented Jul 22, 2016

Hey @mickaelmonsieur, is there any other way we can contact (via Twitter DM or Facebook Messages) so we can solve this?
I just downloaded the example project and everything works here.

@shenyufei
Copy link

I have the same problem. How to solve?
In ios10, the first installation of the application, not pop-up dialog.
But I quit application, then the second time, to open is no problem.

When i set rootViewController programmatically in AppDelegate, DatePickerDialog not working anymore.

@mayurdzk
Copy link

It works fine for me. Would you like to share the code that you're trying to run?

@shenyufei
Copy link

shenyufei commented Oct 24, 2016

` window = UIWindow(frame: UIScreen.mainScreen().bounds)

            window?.backgroundColor = UIColor.whiteColor()

            window?.rootViewController = MainViewController()

            window?.makeKeyAndVisible()`

When I click on the button, it will run the function. (selectDate())
And I added the two parameters in your code. max and min.

`
func selectDate(){
DatePickerDialog().show("选择日期,最早日期为16-9-1", max: checkMax(), min:minDate,doneButtonTitle: "确定", cancelButtonTitle: "取消", datePickerMode: .Date) {
(date) -> Void in

        self.selDate = date
        print("selectDate ->\(self.selDate)")
        self.checkMax()
        self.setTitleText()
        self.ottLoad()

    }
}`

.

`
func show(title: String, max: NSDate,min: NSDate,doneButtonTitle: String, cancelButtonTitle: String, defaultDate: NSDate = NSDate(), datePickerMode: UIDatePickerMode = .DateAndTime, callback: ((date: NSDate) -> Void)) {

    self.title = title
    self.doneButtonTitle = doneButtonTitle
    self.cancelButtonTitle = cancelButtonTitle
    self.datePickerMode = datePickerMode
    self.callback = callback
    self.defaultDate = defaultDate
    self.dialogView = createContainerView()
    self.datePicker.maximumDate = max
    self.datePicker.minimumDate = min

    self.dialogView!.layer.shouldRasterize = true
    self.dialogView!.layer.rasterizationScale = UIScreen.mainScreen().scale

    self.layer.shouldRasterize = true
    self.layer.rasterizationScale = UIScreen.mainScreen().scale

    self.dialogView!.layer.opacity = 0.5
    self.dialogView!.layer.transform = CATransform3DMakeScale(1.3, 1.3, 1)

    self.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0)

    self.addSubview(self.dialogView!)

    /* Attached to the top most window (make sure we are using the right orientation) */
    let interfaceOrientation = UIApplication.sharedApplication().statusBarOrientation

    switch(interfaceOrientation) {
    case UIInterfaceOrientation.LandscapeLeft:
        let t: Double = M_PI * 270 / 180
        self.transform = CGAffineTransformMakeRotation(CGFloat(t))
        break

    case UIInterfaceOrientation.LandscapeRight:
        let t: Double = M_PI * 90 / 180
        self.transform = CGAffineTransformMakeRotation(CGFloat(t))
        break

    case UIInterfaceOrientation.PortraitUpsideDown:
        let t: Double = M_PI * 180 / 180
        self.transform = CGAffineTransformMakeRotation(CGFloat(t))
        break

    default:
        break
    }

    self.frame = CGRectMake(0, 0, self.frame.width, self.frame.size.height)
    UIApplication.sharedApplication().windows.first!.addSubview(self)

    /* Anim */
    UIView.animateWithDuration(
        0.2,
        delay: 0,
        options: UIViewAnimationOptions.CurveEaseInOut,
        animations: { () -> Void in
            self.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.4)
            self.dialogView!.layer.opacity = 1
            self.dialogView!.layer.transform = CATransform3DMakeScale(1, 1, 1)
        },
        completion: nil
    )
}`

@shenyufei
Copy link

shenyufei commented Oct 25, 2016

IOS10 have this problem.But IOS9 there is no problem.

@benjohnde
Copy link
Contributor

Hmm works for me on iOS10.

@shenyufei
Copy link

shenyufei commented Oct 25, 2016

When i set rootViewController programmatically in AppDelegate, DatePickerDialog not working anymore.
But I quit application, then the second time, to open is no problem. @benjohnde
If you try, I believe you'll also have the same problem.
I use Xcode 7.3 ,swift 2.3 , and ios 10
@lfarah Please Help~

@shenyufei
Copy link

Hi,guys, I'm not kidding. why do not you answer me? @benjohnde @lfarah

@benjohnde
Copy link
Contributor

I will look into this issue in more depth on Monday.

@benjohnde
Copy link
Contributor

Do you have any example project regarding your use case? You could create a repo, this would make things easier for us to deep dive into your issue.

@lfarah
Copy link
Collaborator

lfarah commented Nov 4, 2016

@nschucky can you give a help?

@shenyufei
Copy link

Sorry, I'm a rookie. I won't create a repo.
But I believe that if you do this, you will also appear this bug.
When i set rootViewController programmatically in AppDelegate, DatePickerDialog not working anymore.
In ios 10. @benjohnde
Sorry.

@benjohnde
Copy link
Contributor

@shenyufei I think it is not really an effort for you to provide us with a sample project. You ask for help -- we want to help! We are not kidding either. I can not reproduce your bug on iOS 10, even when playing around with the UIWindow and rootViewController.

If you won't create a repo, nobody can help you. Here you can see what I tried to reproduce your bug: https://github.com/benjohnde/DialogAppearance.

Works fine for me. I guess you have two options: think about your code and debug it yourself or provide us with code, that does not work.

Cheers!

@shenyufei
Copy link

shenyufei commented Nov 29, 2016

Hi, I know how to create a repo, and really have problems, please look at
https://github.com/shenyufei/DialogAppearExample
@benjohnde

@benjohnde
Copy link
Contributor

benjohnde commented Nov 29, 2016

It's working for me! Using iOS 10.1 (Simulator and Device) and Xcode 8.1 (8B62). I converted your code to the most recent Swift 2.3 Syntax.

@shenyufei
Copy link

shenyufei commented Nov 29, 2016

Sorry, I tried last week is a bug, but no bug on the upload, so I find the problem, I will contact you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants