私はUITableFieldの値を取得したいと思います。 - カスタムUItableViewCellからUITextfield値を取得する方法。 UITableViewCellに複数のUITextFieldがある場合、タグのプロパティを使用せずに
cellForRowAtIndexPathコードは
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(isShippingShow){
switch (indexPath.section){
case 0:
{
CardListCell *cell = (CardListCell*)[tableView dequeueReusableCellWithIdentifier:@"CardListCell" forIndexPath:indexPath];
return cell;
}
break;
case 1:
{
NewCardCell *cell = (NewCardCell*)[tableView dequeueReusableCellWithIdentifier:@"NewCardCell" forIndexPath:indexPath];
return cell;
}
break;
case 2:
case 3:
{
PayAddressCell *cell = (PayAddressCell*)[tableView dequeueReusableCellWithIdentifier:@"PayAddressCell" forIndexPath:indexPath];
cell.txtCountry.delegate = self;
cell.txtCountry.inputView = _pickerView;
[self setTextFieldAccessoryView:cell.txtCountry];
return cell;
}
break;
case 4:
{
SettingCell *cell = (SettingCell*)[tableView dequeueReusableCellWithIdentifier:@"SettingCell" forIndexPath:indexPath];
[cell.swSetting addTarget:self action:@selector(changeState:) forControlEvents:UIControlEventValueChanged];
return cell;
}
break;
default:
break;
}
}
else{
switch (indexPath.section){
case 0:{
CardListCell *cell = (CardListCell*)[tableView dequeueReusableCellWithIdentifier:@"CardListCell" forIndexPath:indexPath];
return cell;
}
break;
case 1:{
NewCardCell *cell = (NewCardCell*)[tableView dequeueReusableCellWithIdentifier:@"NewCardCell" forIndexPath:indexPath];
return cell;
}
break;
case 2:
{
PayAddressCell *cell = (PayAddressCell*)[tableView dequeueReusableCellWithIdentifier:@"PayAddressCell" forIndexPath:indexPath];
cell.txtCountry.delegate = self;
cell.txtCountry.inputView = _pickerView;
[self setTextFieldAccessoryView:cell.txtCountry];
return cell;
}
break;
case 3:
{
SettingCell *cell = (SettingCell*)[tableView dequeueReusableCellWithIdentifier:@"SettingCell" forIndexPath:indexPath];
[cell.swSetting addTarget:self action:@selector(changeState:) forControlEvents:UIControlEventValueChanged];
return cell;
}
break;
default:
break;
}
}
return [UITableViewCell new];
}
カスタムセルクラスがれたままであるれたままである
#import <UIKit/UIKit.h>
@interface NewCardCell : UITableViewCell
@property(nonatomic,weak) IBOutlet UITextField *txtCardHolderName;
@property(nonatomic,weak) IBOutlet UITextField *txtCardNumber;
@property(nonatomic,weak) IBOutlet UITextField *txtExpDate;
@property(nonatomic,weak) IBOutlet UITextField *txtCVV;
@end
@interface CardListCell : UITableViewCell
@property(nonatomic,weak) IBOutlet UILabel *lblCount;
@property(nonatomic,weak) IBOutlet UILabel *lblCardNumber;
@property(nonatomic,weak) IBOutlet UIImageView *imgCardIcon;
@property(nonatomic,weak) IBOutlet UIButton *btnSelectCard;
@end
@interface SettingCell : UITableViewCell
@property(nonatomic,weak) IBOutlet UILabel *lblCaption;
@property(nonatomic,weak) IBOutlet UISwitch *swSetting;
@end
@interface PayAddressCell : UITableViewCell
@property(nonatomic,weak) IBOutlet UITextField *txtAddress;
@property(nonatomic,weak) IBOutlet UITextField *txtCity;
@property(nonatomic,weak) IBOutlet UITextField *txtState;
@property(nonatomic,weak) IBOutlet UITextField *txtZipcode;
@property(nonatomic,weak) IBOutlet UITextField *txtCountry;
@end
cellrowatindexテーブルビューデリゲートメソッド –
で質問を更新してください。なぜ、タグプロパティを使用したくないのですか? uitextfieldを簡単に取得できるようになります – ajjjjjjjj
Scrollviewのテキストフィールドを使用してみませんか? もっと簡単になります –