原文出自:http://8590847.blog.51cto.com/8580847/1385803
-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
-
{
-
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
-
self.window.backgroundColor = [UIColor whiteColor];
-
//下面两行为增加的代码
-
ViewController *rootViewController = [[ViewController alloc] init];
-
[self.window setRootViewController:rootViewController];
-
-
[self.window makeKeyAndVisible];
-
return YES;
-
}
-
- (void)viewDidLoad
-
{
-
[super viewDidLoad];
-
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(30.0, 64.0, 260.0, 300.0)];
-
[scrollView setBackgroundColor:[UIColor redColor]];
-
-
UIView *view = [[UIView alloc] initWithFrame:scrollView.bounds];
-
[view setBackgroundColor:[UIColor blueColor]];
-
[scrollView addSubview:view];
-
-
[self.view addSubview:scrollView];
-
}
-
ViewController *rootViewController = [[ViewController alloc] init];
-
UINavigationController *navController = [[UINavigationController alloc]
-
initWithRootViewController:rootViewController];
-
[self.window setRootViewController:navController];
-
self.automaticallyAdjustsScrollViewInsets = NO;
-
- (void)viewDidLoad
-
{
-
[super viewDidLoad];
-
-
UIView *firstSubView = [[UIView alloc] initWithFrame:self.view.bounds];
-
[self.view addSubview:firstSubView];
-
-
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(30.0, 64.0, 260.0, 300.0)];
-
[scrollView setBackgroundColor:[UIColor redColor]];
-
-
UIView *view = [[UIView alloc] initWithFrame:scrollView.bounds];
-
[view setBackgroundColor:[UIColor blueColor]];
-
[scrollView addSubview:view];
-
-
[self.view addSubview:scrollView];
-
}
-
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(30.0, 64.0, 260.0, 300.0)];
-
[scrollView setBackgroundColor:[UIColor redColor]];
-
-
CGRect viewFrame = CGRectMake(0, -64.0, CGRectGetWidth(scrollView.frame),
-
CGRectGetHeight(scrollView.frame));
-
-
UIView *view = [[UIView alloc] initWithFrame: viewFrame];
-
[view setBackgroundColor:[UIColor blueColor]];
-
[scrollView addSubview:view];
-
-
[self.view addSubview:scrollView];