fareast555 / MPC_Notification

Highly customizable UILocalNotification-style alert/notification view in Objective C
BSD 2-Clause "Simplified" License
3 stars 0 forks source link

Allow Pan or Tag Gesture to trigger segue #1

Open dutchie027 opened 7 years ago

dutchie027 commented 7 years ago

Is it possible to override the instance allowing a tap or pan to trigger a segue to another VC in lieu of just dismissing? i.e. by default the tap/pan override would dismiss, but if you wanted to pass a VC as a 5th parameter to the instancetype it would segue to that VC on tap/pan?

fareast555 commented 7 years ago

Hi. That's a good idea. The notification view itself wouldn't be the place to push a vc onto the stack. I'll throw in a delegate protocol that will ping the presenting view when the user taps. Give me a few mins and I'll push an update to git. Might take a while for me to get the cocoa pod updated.

fareast555 commented 7 years ago

OK, I just updated the repository. I'll update the CocoaPod when I have a few minutes tomorrow.

Add after the interface declaration of your calling class. Then set the delegate --> myNotification.delegate = self.

The callback comes to the delegate method userDidTapMPC_NotificationView:

Let me know if you see any issues with it. Thanks a lot for the idea.

dutchie027 commented 7 years ago

Looks great and works pretty good, but for some reason on XCode 9 it's throwing

Assigning to 'id _Nullable' from incompatible type 'DashboardTableViewController *const __strong

Its still calling the delegate and compiling, but not sure if the warning is something to heed or just another XCode error being thrown...

fareast555 commented 7 years ago

Good morning! Glad to hear it's doing what you want.

That warning you're seeing usually indicates that the calling class has not declared that it conforms to the delegate profile. Did you do the following? (I'll put both Objective C and Swift)

Objective-C: @interface DashboardTableViewController () @ end

Swift: extension DashboardTableViewController: MPC_NotificationDelegate { func userDidTapMPC_NotificationView -- Deal with the method in your swift code here } }