UIlabelとUITextFieldを持つカスタムUITableViewCellを作成しました。UITableFieldテキストをUITableViewから取得
私はカスタムテーブルをロードして表示し、私のfirstViewControllerで:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
LoginTableCell *cell = (LoginTableCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"LoginTableCell" owner:nil options:nil];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = (LoginTableCell *) currentObject;
break;
}
}
}
次に、ユーザが、私はそこからUITextField.text値を取得し、文字列にそれを保存したい「ログイン」当たったとき。
- (IBAction)login:(id)sender {
これは簡単なことかもしれませんが、私はこれに固執しており、解決する正しい答えを見つけることができないようです。
私はこのような何かを考えていた:サムは
request for member 'text' in something not a structure or union
任意の助けを感謝
おかげ
:NSString *user = LoginTableCell.loginTextField.text;
が、これは誤差を返します
LoginTableCell.loginTextField.textの代わりに、オブジェクト名を使用します。例えば。 currentObject.loginTextField.text – mayuur