IPhoneInstance implementation dialog boxViewIs the content to be introduced in this article. Recently, complex forms need to be written in the project, and the date and multi-choice box content need to be added.ViewAdd related information. Here is a prototype used to help colleagues make complicated forms.
Imitation effect:
Implementation results:
The implementation steps are as follows:
Create a project named iphone_sprintview
Create a subclass SecondView that inherits UIView
Create a SecondView. xib instance.
Open SecondView. xib and perform the following operations:
Add View
Add the declaration of the corresponding control to iphone_sprintviewViewController.
- IBOutlet UIDatePicker *myDataPicker;
- IBOutlet UIView *myView;
Control Association.
Related code: # 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
-
- # 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];
- // Set the border of the layer to a circle
- Self. myView. layer. cornerRadius = 8;
- Self. myView. layer. masksToBounds = YES;
- // Add a colored border to the Layer
- 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
Source code: http://easymorse-iphone.googlecode.com/svn/trunk/iphone.sprintview/
Summary:IPhoneInstance implementation dialog boxViewI hope this article will help you!