Advertisement
csaki

iphone gyak 1

Feb 12th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ViewController.h kiegészítése:
  2. // -(void)kattintas:(UIButton*)sender;
  3.  
  4. //
  5. //  ViewController.m
  6. //  sikerelmeny_proba2
  7. //
  8. //  Created by Hallgato on 2014.02.12..
  9. //  Copyright (c) 2014 __MyCompanyName__. All rights reserved.
  10. //
  11.  
  12. #import "ViewController.h"
  13.  
  14. @interface ViewController ()
  15.  
  16. @end
  17.  
  18. @implementation ViewController
  19.  
  20. - (void)viewDidLoad
  21. {
  22.     [super viewDidLoad];
  23.     // Do any additional setup after loading the view, typically from a nib.
  24.     self.view.backgroundColor=[UIColor whiteColor];
  25.    
  26.     UILabel *label =[[UILabel alloc] initWithFrame:CGRectMake(10, 50, 120, 30)];
  27.     label.tag=999; // ez mindegy mennyi
  28.     label.text=@"hello world";
  29.     [self.view addSubview:label];
  30.     [label release];
  31.    
  32.     UITextField *textfield=[[UITextField alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
  33.     textfield.tag=1000;
  34.     textfield.borderStyle = UITextBorderStyleRoundedRect;
  35.     [self.view addSubview:textfield];
  36.     [textfield release];
  37.    
  38.     UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
  39.     button.frame=CGRectMake(120, 10, 100, 30);
  40.     [button setTitle:@"Button" forState:UIControlStateNormal];
  41.     [button addTarget:self action:@selector(kattintas:) forControlEvents:UIControlEventTouchUpInside];
  42.     [self.view addSubview:button];
  43.    
  44. }
  45.  
  46. -(void)kattintas:(UIButton *)sender
  47. {
  48.     UITextField *textfield=(UITextField*)[self.view viewWithTag:1000];
  49.     UILabel *label=(UILabel*)[self.view viewWithTag:999];
  50.     label.text=[NSString stringWithFormat:@"Hello %@", textfield.text];
  51. }
  52.  
  53. - (void)viewDidUnload
  54. {
  55.     [super viewDidUnload];
  56.     // Release any retained subviews of the main view.
  57. }
  58.  
  59. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  60. {
  61.     return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
  62. }
  63.  
  64. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement