IPhone instance implementation pop-up box View

Source: Internet
Author: User

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.

 
 
  1. IBOutlet UIDatePicker *myDataPicker;   
  2. IBOutlet UIView *myView; 

Control Association.

Related code: # import <UIKit/UIKit. h>

 
 
  1. # Import "SecondView. h"
  2. @ Interface iphone_sprintviewViewController: UIViewController {
  3. SecondView * mySecondView;
  4. IBOutlet UIDatePicker * myDataPicker;
  5. IBOutlet UIView * myView;
  6. }
  7. @ Property (nonatomic, retain) SecondView * mySecondView;
  8. @ Property (nonatomic, retain) UIDatePicker * myDataPicker;
  9. @ Property (nonatomic, retain) UIView * myView;
  10. -(IBAction) onClickButton :( id) sender;
  11. @ End
  12.  
  13. # Import "iphone_sprintviewViewController.h"
  14. # Import <QuartzCore/QuartzCore. h>
  15. @ Implementation iphone_sprintviewViewController
  16. @ Synthesize mySecondView, myDataPicker, myView;
  17. -(Void) viewDidLoad
  18. {
  19. Self. mySecondView = [[SecondView alloc] init];
  20. NSArray * array = [[NSBundle mainBundle] loadNibNamed: @ "SecondView"
  21. Owner: self options: nil];
  22. Self. mySecondView = [array objectAtIndex: 0];
  23. // Set the border of the layer to a circle
  24. Self. myView. layer. cornerRadius = 8;
  25. Self. myView. layer. masksToBounds = YES;
  26. // Add a colored border to the Layer
  27. Self. myView. layer. borderWidth = 8;
  28. Self. myView. layer. borderColor = [[UIColor colorWithRed: 0.52 green: 0.09 blue: 0.07 alpha: 0.5] CGColor];
  29. }
  30. -(Void) didReceiveMemoryWarning {
  31. [Super didReceiveMemoryWarning];
  32. }
  33. -(Void) viewDidUnload {
  34. Self. mySecondView = nil;
  35. Self. myDataPicker = nil;
  36. Self. myView = nil;
  37. }
  38. -(Void) dealloc {
  39. [Self. myView release];
  40. [Self. mySecondView release];
  41. [Self. myDataPicker release];
  42. [Super dealloc];
  43. }
  44. -(IBAction) onClickButton :( id) sender
  45. {
  46. If ([sender tag] = 0 ){
  47. [Self. view addSubview: mySecondView];
  48. } Else if ([sender tag] = 1 ){
  49. [MySecondView removeFromSuperview];
  50. } Else {
  51. NSLog (@ "= % @", self. myDataPicker. date );
  52. [MySecondView removeFromSuperview];
  53. }
  54. }
  55. @ End

Source code: http://easymorse-iphone.googlecode.com/svn/trunk/iphone.sprintview/

Summary:IPhoneInstance implementation dialog boxViewI hope this article will help you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.