andreamazz / AMScrollingNavbar

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
MIT License
6.05k stars 633 forks source link

Objektiv C - not working tutorial #327

Closed StefaniOSApps closed 5 years ago

StefaniOSApps commented 5 years ago

Describe the bug I can not use the following line

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [(ScrollingNavigationController *)self.navigationController followScrollView:self.tableView delay:50.0f];
}

what can I do?

Screenshots

bildschirmfoto 2018-10-09 um 09 39 50
andreamazz commented 5 years ago

Did you import the library?

@import AMScrollingNavbar;
StefaniOSApps commented 5 years ago

Yes of course, it's not my first framework.

first - connect with cocoa-pods

bildschirmfoto 2018-10-09 um 13 09 21 bildschirmfoto 2018-10-09 um 13 09 17

second - import Framework

bildschirmfoto 2018-10-09 um 13 11 50

I use Xcode v10.0

andreamazz commented 5 years ago

Ok, there was a missing NSObject inheritance in one of the objects, so it wasn't exposed in ObjC. It's fine now, checkout the updated readme.

StefaniOSApps commented 5 years ago

Sorry, It's not working...

terminal said:

2018-10-10 21:44:00.012671+0200 Example[3341:505821] -[UINavigationController followScrollView:delay:scrollSpeedFactor:collapseDirection:followers:]: unrecognized selector sent to instance 0x10601d200
2018-10-10 21:44:00.013002+0200 Example[3341:505821] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController followScrollView:delay:scrollSpeedFactor:collapseDirection:followers:]: unrecognized selector sent to instance 0x10601d200'
*** First throw call stack:
(0x1bb413ef8 0x1ba5e1a40 0x1bb32b154 0x1e82465c0 0x1bb419810 0x1bb41b4bc 0x1041f1088 0x1e7c5aa60 0x1e7c5b144 0x1e7bc20e8 0x1e7bc2da8 0x1e7bc40a8 0x1e7ba6298 0x1e86bbf44 0x1bf9f5a34 0x1bf9fa9c4 0x1bf9599d4 0x1bf9882f4 0x1e823336c 0x1bb3a2408 0x1bb3a1d08 0x1bb39ccfc 0x1bb39c5b8 0x1bd610584 0x1e8218bc8 0x1041f154c 0x1bae5cb94)
libc++abi.dylib: terminating with uncaught exception of type NSException

i made a example git: https://github.com/StefaniOSApps/Example

andreamazz commented 5 years ago

From the readme: Make sure to use ScrollingNavigationController instead of the standard UINavigationController. Either set the class of your UINavigationController in your storyboard, or create programmatically a ScrollingNavigationController instance in your code.

StefaniOSApps commented 5 years ago

Thanks for the hint, I had overlooked that.

bildschirmfoto 2018-10-10 um 22 31 34

Unfortunately, this does not change anything, even with the change it does not work.

I have the following log

2018-10-10 22:29:50.313147+0200 Example[3439:518696] Unknown class ScrollingNavigationController in Interface Builder file.
2018-10-10 22:29:50.392339+0200 Example[3439:518696] -[UINavigationController followScrollView:delay:scrollSpeedFactor:collapseDirection:followers:]: unrecognized selector sent to instance 0x10281c400
2018-10-10 22:29:50.392722+0200 Example[3439:518696] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController followScrollView:delay:scrollSpeedFactor:collapseDirection:followers:]: unrecognized selector sent to instance 0x10281c400'
*** First throw call stack:
(0x1bb413ef8 0x1ba5e1a40 0x1bb32b154 0x1e82465c0 0x1bb419810 0x1bb41b4bc 0x100da5088 0x1e7c5aa60 0x1e7c5b144 0x1e7bc20e8 0x1e7bc2da8 0x1e7bc40a8 0x1e7ba6298 0x1e86bbf44 0x1bf9f5a34 0x1bf9fa9c4 0x1bf9599d4 0x1bf9882f4 0x1e823336c 0x1bb3a2408 0x1bb3a1d08 0x1bb39ccfc 0x1bb39c5b8 0x1bd610584 0x1e8218bc8 0x100da554c 0x1bae5cb94)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

I have already changed the example of GIT according to the current state of knowledge. https://github.com/StefaniOSApps/Example

andreamazz commented 5 years ago

As the log suggests:

2018-10-10 22:29:50.313147+0200 Example[3439:518696] Unknown class ScrollingNavigationController in Interface Builder file.

You need to set the navigation controller to that class, that is present in the framework's module, like so (taken from the sample of this repo...):

screenshot 2018-10-10 at 22 42 15
StefaniOSApps commented 5 years ago

perfect, it works now. could you add a objectiv-c demo, like this https://github.com/StefaniOSApps/Example

thanks 4 your help

StefaniOSApps commented 5 years ago

I have one last question

My UINavigationController has its own "ViewControllerNavigation.h" and "ViewControllerNavigation.m" file

If I replace here in the ".h" "UINavigationController" by "ScrollingNavigationController" an error message comes up.

bildschirmfoto 2018-10-11 um 08 38 45 bildschirmfoto 2018-10-11 um 08 42 41

Unfortunately I can not select "ViewControllerNavigation" as class and "AMScrollingNavbar" as module. Only the combination "ScrollingNavigationController" as class and "AMScrollingNavbar" as module is possible.

Is there a simple solution here?

andreamazz commented 5 years ago

You can't subclass a swift class from ObjC.