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 06-23-2010, 08:06 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 2
rukiman is on a distinguished road
Default adding view of another UIViewController to a UIViewController causes black gap

I have written a UIViewController that is to manage UIViewControllers in a similar way to the UITabBarController except I didn't want the bottom tab GUI. In a nutshell what my UITabBarControllerCustomer does it keeps all the view controllers in an array and then adds and removes the view of the view controllers as required to work like a tab controller. Everything is working as I expect however I get an unwanted black gap at the top of the my screen just after the status bar (battery etc). This gap seems exactly like the height of the status bar. How can I get rid of this black bar?


Here is my code:

*******TestApplication.m*****
#import "TestApplication.h"
#import "ViewController1.h"

@implementation TestApplication

@synthesize window;
@synthesize tabBarController;


- (UIView *)applicationStartWithSettings
{
ViewController1 *viewcontroller1 = [[[ViewController1 alloc]
initWithStyle:UITableViewStyleGrouped] autorelease];

tabBarController = [[UITabBarControllerCustom alloc] initWithViewControllers:[NSArray arrayWithObjects:
viewcontroller1, nil]];

return tabBarController.view;
}



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[window addSubview: [self applicationStartWithSettings]];
[window makeKeyAndVisible];

return true;
}


- (void)dealloc
{
[tabBarController release];
[window release];
[super dealloc];
}

@end



********UITabBarControllerCustom.m*******

#import "UITabBarControllerCustom.h"

@implementation UITabBarControllerCustom

- (id)initWithViewControllers:(NSArray *)viewControllers
{
if (self = [super init])
{
viewcontrollers = [[NSMutableArray alloc] init];
int count = [viewControllers count];
for(int i=0; i<count; i++)
{
UIViewController *vc = [viewControllers objectAtIndex:i];
[viewcontrollers addObject:vc];
}
currentViewIndex = 0;
}

return self;
}

- (void) setSelectedIndex:(int)index
{
// removing current view
UIViewController *viewcontroller = [viewcontrollers objectAtIndex:currentViewIndex];
[viewcontroller viewWillDisappear:NO];
[viewcontroller.view removeFromSuperview];
[viewcontroller viewDidDisappear:NO];

// adding new view
currentViewIndex = index;
viewcontroller = [viewcontrollers objectAtIndex:currentViewIndex];
[viewcontroller viewWillAppear:NO];
[self.view addSubview:viewcontroller.view];
[viewcontroller viewDidAppear:NO];
}

- (int) selectedIndex
{
return currentViewIndex;
}

- (void) viewWillAppear:(BOOL)animated
{
// display the correct uiviewcontroller
[self setSelectedIndex:currentViewIndex];
}

- (void)dealloc
{
[viewcontrollers dealloc];
[super dealloc];
}

@end


*********ViewController1.m**********

#import "ViewController1.h"
#import "TestApplication.h"


@implementation ViewController1

- (id)initWithStyle:(UITableViewStyle)style
{
if (self = [super initWithStyle:style])
{
self.title = NSLocalizedString(@"ViewController1", @"ViewController1View");
}

return self;
}

- (void)dealloc
{
[super dealloc];
}


@end
rukiman is offline   Reply With Quote
Old 06-23-2010, 08:39 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 2
rukiman is on a distinguished road
Default

Adding this line

self.view.frame = [[UIScreen mainScreen] bounds];

in UITabBarControllerCustom.m in initWithViewController() removed the black bar when the application started, however when I show a modal UIViewController and come back once again the black bar appears. ( Any ideas??
rukiman is offline   Reply With Quote
Reply

Bookmarks

Tags
uitabbarcontroller, uiviewcontroller

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: 323
7 members and 316 guests
anothermine, Chickenrig, Domele, givensur, michaelhansen, PixelInteractive, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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