psy2k / NMPopUpView

Simple Swift class for iOS that shows nice popup windows with animation.
MIT License
194 stars 30 forks source link

Close Button doesn't work in Swift #9

Closed omardlhz closed 9 years ago

omardlhz commented 9 years ago

I've read all the issues and I still cant manage to make the close button work. I imported the PopUpViewController.xib and the PopUpViewControllerSwift.swift files, do I need to import any other files?

psy2k commented 9 years ago

@omardlhz In order to use the Swift version, you have to import the PopUpViewControllerSwift.Swift file and all the .xibs and make sure that the IBAction for the close button is connected. popup

See the DemoViewController.swift for how to initialize and use the PopUp in your View Controller. Let me know if the issue still exists.

rizwan95 commented 9 years ago

I am also expereincing the same issue. Everything is fine but when the close button is clicked , the app crashes.

psy2k commented 9 years ago

@rizwan95 can you post the crash log?

rizwan95 commented 9 years ago

The error which I get after I press the close button is, Thread 1 : Exc_Bad_Access(Code=EXC_i386_GPFLT) in the app delegate class.

psy2k commented 9 years ago

@rizwan95 enable breakpoints exceptions in the exceptions tab and please post the line where the crash occurs.

screen shot 2015-06-13 at 15 12 51

sorennorup commented 9 years ago

I'm also interested in a fix of this issue with the close button.

jameswalkerkerr commented 9 years ago

I am having the same issue. Here is the zombie message that I am given: "An Objective-C message was sent to a deallocated 'DealPeel.PopUpViewControllerSwift' object (zombie) at address: 0x126d42880. ". My app name is 'DealPeel'.

Here are the messages is in the console: screen shot 2015-06-17 at 5 55 10 pm

psy2k commented 9 years ago

@jameswalkerkerr the popUp is deallocated. Are you declaring it as a weak property?

break2k commented 9 years ago

any progress here ?

psy2k commented 9 years ago

@break2k can you set a exception breakpoint and post here the code that causes the crash?

einali commented 9 years ago

pls fix this issue

psy2k commented 9 years ago

@einali please see the above answer and post the line that causes the crash using an exception breakpoint.

Marcellsantoso commented 9 years ago

i still can't get the error log, it's only showing Exc_Bad_Access(Code=EXC_i386_GPFLT), and i've tried adding the exception breakpoint, and it's still like that. Please help :(

Kecemen commented 9 years ago

We just need #import "NMPopUpView-Swift.h" this class how can i import this ?

psy2k commented 9 years ago

@Kecemen if you are using swift classes in your objectivec classes you have to import the -Swift.h generated header in your objective-c classes (only where you want to use your swift classes_. This header is named YourProjectName-Swift.h. For example if your project is named "Kecemen" your swift header will be Kecemen-Swift.h.

Kecemen commented 9 years ago

screen shot 2015-08-11 at 18 26 49

Nevermind i decide to use obj-c class and i changed .xib file class. Also, import

import "PopUpViewController.h"

PopUpViewController *popViewController = [[PopUpViewController alloc]
                                          initWithNibName:@"PopUpViewController" bundle:nil];
[popViewController setTitle:@"This is a popup view"];
[popViewController showInView:self.view
                    withImage:[UIImage imageNamed:@"yourImage"]
                  withMessage:@"Your Message" animated:YES];

this code part.

Popup show working but when i click close app crashed. Than i delete close button action connection than i run. this time, when i click close app not crash but close button do nothing. I cound't find error ?

Kecemen commented 9 years ago

I fixed problem create UIView and set on .xib view and than set button action screen shot 2015-08-11 at 18 30 02 screen shot 2015-08-11 at 18 30 56

Now popup closed. If anyone want i can send my code.

psy2k commented 9 years ago

@Kecemen you can patch the example of the repo and submit a pull request here if you want :-)

Kecemen commented 9 years ago

I created pull request but i don't know how can i download my codes.

ghost commented 9 years ago

So.... What is the solution in the Swift language?

psy2k commented 9 years ago

@Brain2success a new version will be available soon, with cocoapods support and it will be only, which will fix this issue. Meanwhile just disconnect the close action from the .xibs and add it again.

ghost commented 9 years ago

Well tanks for the quick response! Instead of disconnect and add it again, I added a new UIButton and connected to the swift file. Just with a simple println("test"). But it also resolve in the same error.

psy2k commented 9 years ago

@Brain2success what error are you getting? I am unable to reproduce this. If you can put a debug breakpoint and send me the line that crashes it will be great. Also if you are able to reproduce this issue in a test product and upload it here, you can give me access and I will be able to see what is going wrong.

ghost commented 9 years ago

https://github.com/Brain2success/popUpView.git here you find a simple test product I even added a extra button like i did in the original.

ghost commented 9 years ago

@psy2k did you tried the link I send you? And are you able to reproduce the error?

psy2k commented 9 years ago

@Brain2success the problem is that you declare the popUpViewController property in the method where you calling it. That causes it to be released after presenting, so the close action is sent to a deallocated instance which causes a crash. Declare the property in the class variables from where you are going to call the popup var popViewController = PopUpViewControllerSwift(nibName: "PopUpViewController_iPad", bundle: nil) and in the method. If your viewcontroller is written in ObjC declare the popup property in the interface with a strong reference.

psy2k commented 9 years ago

@Brain2success I will commit the fix to your repository so anyone here can see whats changed (You have to give me push access to the repo for that). The correct implementation is also available in the examples provided by this repo.

ghost commented 9 years ago

Hello,

I think you should have access to the files now. Is that correct?

Brain2Success

On wo, sep. 9, 2015 at 11:33 p.m., psy2k/NMPopUpView reply@reply.github.com wrote:

Closed #9https://github.com/psy2k/NMPopUpView/issues/9.

— Reply to this email directly or view it on GitHubhttps://github.com/psy2k/NMPopUpView/issues/9#event-405320843.

psy2k commented 9 years ago

@Brain2success I've pushed the fix https://github.com/Brain2success/popUpView/commit/8a613e1d1db8d38c3b4d0dade7a9840710995f33

sai487 commented 8 years ago

@Kecemen please send ur code my mail id is saikrishna.tadavarthy@gmail.com

psy2k commented 8 years ago

@sai487 you can subclass the popup so you can override the close function and add custom code for it.