Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @implementation ViewController
- @synthesize name = _name ;
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- int y = 20 ;
- for(int i=1; i <= 10; i++)
- {
- CGRect frame = CGRectMake(20, y, 100, 30 ) ;
- name = [[UITextField alloc] initWithFrame:frame];
- [name setTag:i] ;
- [name setBackgroundColor:[UIColor whiteColor]] ;
- [name addTarget:self action:@selector(makeBlue:) forControlEvents:UIControlEventTouchDown];
- [self.view addSubview:name];
- y += 38;
- }
- }
- - (void)makeBlue:(id)sender
- {
- int i = (int)[sender tag] ;
- [name setTag:i] ;
- NSLog(@"%d", i);
- [name setBackgroundColor:[UIColor blueColor]] ;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- int y = 20 ;
- for(int tag=1; tag <= 10; tag++)
- {
- CGRect frame = CGRectMake(20, y, 100, 30 ) ;
- name = [[UITextField alloc] initWithFrame:frame];
- [name setTag:tag] ;
- [name setBackgroundColor:[UIColor whiteColor]] ;
- [name addTarget:self action:@selector(makeItSo:) forControlEvents:UIControlEventEditingDidEnd];
- [self.view addSubview:name];
- [name setDelegate:self] ;
- y += 38;
- }
- }
- - (void)makeItSo:(id)sender
- {
- int tag = (int)[sender tag] ;
- [name setTag:tag] ;
- NSString * aName = [name text] ;
- NSLog(@"%@", aName) ;
- }
- [self.view viewWithTag:<tag>]
- - (void)makeBlue:(id)sender
- {
- int tag = (int)[sender tag] ;
- UIView *tagView = [self.view viewWithTag:tag]
- [tagView setBackgroundColor:[UIColor blueColor]] ;
- }
- name = [self.view viewWithTag:[sender tag]];
- NSString *fieldText = name.text;
- NSInteger i = [sender tag];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement