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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-15-2010, 02:59 PM   #5 (permalink)
Dr.Lightning
Registered Member
 
Join Date: Feb 2010
Posts: 13
Default

I'm convinced that the Hello World tutorial has an error in it.

Can somebody else please do the following:

1) Begin by following the tutorial at:
iPhone Dev Center: Your First iPhone Application: Introduction

2) By the time you finish the "Inspecting the Nib File" page (5th page), when you run the app in the simulator you'll see a purple background.

3) However, there's a white bar below the purple background. Go back to interface builder and add label text at the very top left and bottom right corners of the MyViewController.xib view. Now when you run the simulator, you find that your top left text is under the status bar, and the bottom right text is above the white bar.

4) Further go back and use the interface builder on the MainWindow.xib that's still white. Add top left and bottom right text to it as well. (I used 48 point so it's tall enough to both position at the very top of the view, as well as later hang down partially below when it's hidden under the status bar.) Run the simulator. You'll see that the white bar at the bottom of the screen is the MainWindow showing at the bottom, and the bottom right text shows as well.

5) Therefore, the purple MyViewController view is positioning under the status bar, and is only high enough assuming it's NOT positioned under the status bar. Therefore, it ends up short, not reaching the bottom of the screen. As a result, you can still see the MainWindow view under it.

I don't think I'm doing anything wrong. Perhaps folks don't notice this when they later have a white background and don't position hello world stuff right up against the edges of the screen.

Code:
//
//  HellowWorldViewAppDelegate.h
//  HellowWorldView
//
//  Created by Helmut Forren on 2/15/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <UIKit/UIKit.h>

@class MyViewController;

@interface HellowWorldViewAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
	MyViewController *myViewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) MyViewController *myViewController;


@end
Code:
//
//  HellowWorldViewAppDelegate.m
//  HellowWorldView
//
//  Created by Helmut Forren on 2/15/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "MyViewController.h";
#import "HellowWorldViewAppDelegate.h"

@implementation HellowWorldViewAppDelegate

@synthesize window;
@synthesize myViewController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    
	MyViewController *aViewController = [[MyViewController alloc]
										 initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
	[self setMyViewController:aViewController];
	[aViewController release];

	
    UIView *controllersView = [myViewController view];
    [window addSubview:controllersView];
	
    // Override point for customization after application launch
    [window makeKeyAndVisible];
}


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


@end
Code:
//
// Prefix header for all source files of the 'HellowWorldView' target in the 'HellowWorldView' project
//

#ifdef __OBJC__
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
#endif
Code:
//
//  main.m
//  HellowWorldView
//
//  Created by Helmut Forren on 2/15/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {
    
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}
Code:
//
//  MyViewController.h
//  HellowWorldView
//
//  Created by Helmut Forren on 2/15/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface MyViewController : UIViewController {

}

@end
Code:
//
//  MyViewController.m
//  HellowWorldView
//
//  Created by Helmut Forren on 2/15/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "MyViewController.h"


@implementation MyViewController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


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


@end
I didn't include the .xib XML because it makes the post too long for the forum software to accept.
Dr.Lightning is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,852
Threads: 89,217
Posts: 380,670
Top Poster: BrianSlick (7,129)
Welcome to our newest member, syrreintyia1
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:05 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.