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

create controller programmatically throws exception #3

Open
thisiscam opened this issue Sep 17, 2014 · 14 comments
Open

create controller programmatically throws exception #3

thisiscam opened this issue Sep 17, 2014 · 14 comments

Comments

@thisiscam
Copy link

I'm experimenting with this controller and figured that it raises NSRange out of bound exception when calling alloc init. it seems that alloc init somehow calls initwithnib, which I don't have any. Is this control only supposed to be used with storyboard?

@bfeher
Copy link
Owner

bfeher commented Sep 18, 2014

Hmm I see. I found where and why it's crashing and I'm thinking of how best to fix this. It crashes because it tries to calculate where to draw the underline before there are even any tabs loaded.

For now I guess it's only usable via storyboard :/

Incidentally, UITabBarControllers always call their initWithNib from within their init methods. Try the same code you have only without subclassing BFPaperTabBarController and you will see, it will call its initWithNib from within init:

2014-09-18 15:11:37.136 bfpapertabbarcontrollerTEST[1324:60b] init start
2014-09-18 15:11:37.136 bfpapertabbarcontrollerTEST[1324:60b] nib start
2014-09-18 15:11:37.137 bfpapertabbarcontrollerTEST[1324:60b] nib end
2014-09-18 15:11:37.138 bfpapertabbarcontrollerTEST[1324:60b] init end

@thisiscam
Copy link
Author

Yeah I have the same observation

Thanks for that insight I suspect something similar earlier but just haven't got the time to test it out. I will just try to use a temporary hack for this for now and if you have any follow up(or there's anything I can help) please let me know

@bfeher
Copy link
Owner

bfeher commented Sep 18, 2014

I have to admit that I am not used to using TabBarController programmatically. I'm always open to accepting pull requests if you happen to figure out a good way to fix this. I will also keep looking into it but I can't promise any timeframe ;)

@thisiscam
Copy link
Author

That's fine. I will definitely pull request if I find good solution. Right now I'm just deleting that initWithNib for this control so that it won't be called

@benvium
Copy link

benvium commented Oct 26, 2014

@thisiscam Did you ever get this working programmatically? I tried deleting the initWithNib method with no luck

@thisiscam
Copy link
Author

You might want to diff with this https://github.com/thisiscam/BFPaperTabBarController/blob/master/Classes/BFPaperTabBarController.m ? I remember commenting out a few lines in init which was super hacky...

@benvium
Copy link

benvium commented Oct 26, 2014

Thanks for the quick response. I had a look at that’s basically what I did too. Not sure why mine isn’t working, I get no theming or ‘tap ripples’ or anything. Will have to try again when I have more time.

On Sun, Oct 26, 2014 at 7:05 PM, Cambridge notifications@github.com
wrote:

You might want to diff with this https://github.com/thisiscam/BFPaperTabBarController/blob/master/Classes/BFPaperTabBarController.m ? I remember commenting out a few lines in init which was super hacky...

Reply to this email directly or view it on GitHub:
#3 (comment)

@Timstarockz
Copy link

Timstarockz commented Nov 30, 2016

If it's not too late, I've modified this class to work programmatically! You can check out the source here! I basically removed all references to IB and refactored/reorganized some of the initialization methods. Now it works like a charm without IB!

https://github.com/Timstarockz/BFPaperTabBarController/tree/master/Classes

@benvium
Copy link

benvium commented Dec 1, 2016

@Timstarockz Thank you!

@bfeher
Copy link
Owner

bfeher commented Dec 2, 2016

@Timstarockz Thanks! I'll take a closer look next week and perhaps make this the standard.

@tobatha
Copy link

tobatha commented Dec 6, 2017

@bfeher so rite now with the latest version, init tab bar controller programmatically is possible?

@bfeher
Copy link
Owner

bfeher commented Dec 7, 2017

@tobatha It hasn't been integrated into the main branch, so please use Timstarockz version above. Thank you.

@tobatha
Copy link

tobatha commented Dec 7, 2017

@bfeher yeah, i tried last nite, seems no luck, but won't crash anymore, that's very reassuring! ^_^

@bfeher
Copy link
Owner

bfeher commented Dec 7, 2017

@tobatha I'm sorry that I have been criminally negligent of my repos lately. Life is getting too busy. If you find anything that needs fixed please let me know and I will try to fix it ASAP :)

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

No branches or pull requests

5 participants