UIViewController use

 

1 appdelegate.m  

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

{

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

    // Override point for customization after application launch.

    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];

    self.window.rootViewController = self.viewController;

    [self.window makeKeyAndVisible];

    return YES;

}

ViewController.h

  @interface ViewController : UIViewController 

3 viewcontroller.m

- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    self.view.backgroundColor=[UIColor brownColor];

    //UIImage *img = [UIImage imageNamed:@"app_bg.png"];

    //self.view.backgroundColor=[UIColor colorWithPatternImage:img];

 

    if(!self.array)

    {

        self.array=[NSArray arrayWithObjects:@"aa",@"bb",@"cc", nil];

    }

    self.title=@"test";

    UILabel* label1=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];

    label1.backgroundColor=[UIColor blackColor];

    label1.text=[self.array objectAtIndex:0];

    [self.view addSubview:label1];

} 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2018-04-10
  • 2018-06-15
  • 2021-05-14
猜你喜欢
  • 2021-12-26
  • 2022-12-23
  • 2022-03-08
  • 2021-07-30
  • 2021-08-13
  • 2021-09-13
  • 2022-12-23
相关资源
相似解决方案