iphone实现弹出框视图

  • 主要文件如下:
  • SecondView.h
//
//  SecondView.h
//  iphone.sprintview
//
//  Created by wangjun on 10-12-1.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface SecondView : UIView {

}
-(IBAction)onClickButton:(id)sender;
@end

 

  • SecondView.m
//
//  SecondView.m
//  iphone.sprintview
//
//  Created by wangjun on 10-12-1.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "SecondView.h"
@implementation SecondView

- (void)dealloc {
    [super dealloc];
}
-(IBAction)onClickButton:(id)sender
{
NSLog(@"dsafdfds");
}
@end
  • iphone_sprintviewAppDelegate.h
//
//  iphone_sprintviewAppDelegate.h
//  iphone.sprintview
//
//  Created by wangjun on 10-12-1.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <UIKit/UIKit.h>

@class iphone_sprintviewViewController;

@interface iphone_sprintviewAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    iphone_sprintviewViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet iphone_sprintviewViewController *viewController;

@end

  • iphone_sprintviewAppDelegate.m
//
//  iphone_sprintviewAppDelegate.m
//  iphone.sprintview
//
//  Created by wangjun on 10-12-1.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "iphone_sprintviewAppDelegate.h"
#import "iphone_sprintviewViewController.h"

@implementation iphone_sprintviewAppDelegate

@synthesize window;
@synthesize viewController;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    // Override point for customization after application launch.

    // Add the view controller's view to the window and display.
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
     */
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    /*
     Called as part of  transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
     */
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}


- (void)applicationWillTerminate:(UIApplication *)application {
    /*
     Called when the application is about to terminate.
     See also applicationDidEnterBackground:.
     */
}


#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    /*
     Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
     */
}


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


@end
  • iphone_sprintviewViewController.h
//
//  iphone_sprintviewViewController.h
//  iphone.sprintview
//
//  Created by wangjun on 10-12-1.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "SecondView.h"
@interface iphone_sprintviewViewController : UIViewController {
	SecondView *mySecondView;
	IBOutlet UIDatePicker *myDataPicker;
	IBOutlet UIView *myView;
}
@property (nonatomic,retain) SecondView *mySecondView;
@property (nonatomic,retain) UIDatePicker *myDataPicker;
@property (nonatomic,retain) UIView *myView;
-(IBAction)onClickButton:(id)sender;
@end

  • iphone_sprintviewViewController.m
//
//  iphone_sprintviewViewController.m
//  iphone.sprintview
//
//  Created by wangjun on 10-12-1.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import "iphone_sprintviewViewController.h"
#import <QuartzCore/QuartzCore.h> 
@implementation iphone_sprintviewViewController
@synthesize mySecondView,myDataPicker,myView;
-(void) viewDidLoad
{
	self.mySecondView=[[SecondView alloc] init];
	NSArray *array =[[NSBundle mainBundle] loadNibNamed:@"SecondView"
												  owner:self options:nil];
	self.mySecondView=[array objectAtIndex:0];
	//灏��惧���杈规�璁剧疆涓哄���� 
    self.myView.layer.cornerRadius = 8; 
	self.myView.layer.masksToBounds = YES; 
    //缁��惧�娣诲��涓�涓����茶竟妗� 
	self.myView.layer.borderWidth = 8; 
	self.myView.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:0.5] CGColor]; 
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
	self.mySecondView=nil;
	self.myDataPicker=nil;
	self.myView=nil;
}
- (void)dealloc {
	[self.myView release];
	[self.mySecondView release];
	[self.myDataPicker release];
    [super dealloc];
}
-(IBAction)onClickButton:(id)sender
{
	if ([sender tag]==0) {
		[self.view addSubview:mySecondView];
	}else if ([sender tag]==1) {
		[mySecondView removeFromSuperview];
	}else {
		NSLog(@"==%@",self.myDataPicker.date);
		[mySecondView removeFromSuperview];
	}
}
@end

 

你可能感兴趣的:(基础,移动开发,iPhone,弹出框,Object-C)