Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-04-2010, 05:10 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 98
SteveMobs is on a distinguished road
Question Problems with removing TabBarController

Before posting (quite complex) code I would just like to say what I want to do and which problems I have.

After starting the App I would like to present a login-view. When the user presses the login button I would like to present a TabBarController with several view controllers. The user also has the chance to logout. When the logout button is pressed, the tab bar controller and all its view controllers should be unloaded/released, and the login view should be loaded again and presented.

Now I am having some serious troubles with the tab bar controller. I tried to wrap it into a separate view controller class, which has a tab bar controller as a property. when doing this loading and unloading the tab bar works fine but no viewWillAppear and similar methods are send to the view controllers of the tab bar. I just don't understand why those messages are not fired!?

So I tried to create a tab bar controller directly in the app delegate in the didFinishLaunchingWithOptions methods. This also works on first sight. even the viewDidAppear and similar methods are fired on the view controllers of the tab bar. The problem here is, that I cannot unload/release the tab bar controller when the user presses the logout button. When sending a release message to the tab bar controller, the app simply crashes!?

[window addSubview:_myLoginViewController.view]; // works
[_myTabBarController.view removeFromSuperview]; // works
[_myTabBarController release]; // crash

What am I doing wrong? Any faults in my logic? How to unload a tab bar controller?

Thank you!
SteveMobs is offline   Reply With Quote
Old 08-04-2010, 11:55 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Well maybe it is as simple as the [_myTabBarController.view removeFromSuperview]; already releases the ViewController too, so the retain count went from 1 to 0, then you try to release from 0, when it is already completely released.

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Old 08-05-2010, 01:24 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 98
SteveMobs is on a distinguished road
Default

Thanks for this suggestion. I tried:
Code:
NSLog(@"tabBar retainCount before removeFromSuperview = %d", [self.tabBarController retainCount]);
[self.tabBarController.view removeFromSuperview];
NSLog(@"tabBar retainCount after removeFromSuperview  = %d", [self.tabBarController retainCount]);
[self.tabBarController release];
which results in the output:
Quote:
tabBar retainCount before removeFromSuperview = 1
tabBar retainCount after removeFromSuperview = 1
Program received signal: “EXC_BAD_ACCESS”.
:-(

I could live with having the tab bar controller in the background all the time but I would like to remove the view controllers at least so that quite some objects get deallocated.
Code:
self.tabBarController.viewController = nil;
This also results in a EXC_BAD_ACCESS... I thought it is possible to remove the view controllers at runtime!?

I was searching the web for any example in which a UITabBarController is removed from the super view. Even the Apple UICatalogue example seems to avoid the tab bar controller.

Last edited by SteveMobs; 08-05-2010 at 01:27 AM.
SteveMobs is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 327
8 members and 319 guests
alexP, gordo26, headkaze, mistergreen2011, nobstudio, rayjeong, Sloshmonster, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:21 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0