-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBSAddPlayerViewController.m
73 lines (63 loc) · 1.83 KB
/
DBSAddPlayerViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// DBSAddPlayerViewController.m
// Kings
//
// Created by David Sanders on 12/15/13.
// Copyright (c) 2013 David Sanders. All rights reserved.
//
#import "DBSAddPlayerViewController.h"
@interface DBSAddPlayerViewController ()
@end
@implementation DBSAddPlayerViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.playerNameTextField becomeFirstResponder];
self.playerNameTextField.delegate = self;
}
- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
//self.player = self.playerNameTextField.text;
//NSString *newPlayer = self.player;
//[self.delegate doneAddingPlayer:newPlayer];
//[self.delegate setValue:newPlayer forKey:@"addPlayerName"];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)textFieldDoneEditing:(id)sender
{
/*
//This was initially used to add the player after the user clicked done and dismissed the keyboard. Now this is all handled below
self.player = self.playerNameTextField.text;
NSString *newPlayer = self.player;
[self.delegate doneAddingPlayer:newPlayer];
self.playerNameTextField.text = @"";
*/
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == self.playerNameTextField)
{
self.player = self.playerNameTextField.text;
NSString *newPlayer = self.player;
[self.delegate doneAddingPlayer:newPlayer];
self.playerNameTextField.text = @"";
return NO;
}
else
return YES;
}
@end