今、私はIOSプログラミングの初心者で、ビューを作成してその中にテーブルビューを配置し、テーブルセルに使用したいテンプレートでxibを作成し、その呼び出し用のクラスを作成しました。表のセルには、ラベル (セルのロード時に設定)、スイッチ、およびテキストフィールドがあります。
テーブルは正常にロードされ、ラベルには正しいテキストが表示されます。データベースからロードされる行は 12 行あります。平方ライト。
問題: 行 1 のテキスト フィールドを編集すると、行 9 のテキスト フィールドが編集され、その逆も同様です。行 2 を編集すると、行 10 が編集されます。行 4,12 までは、テキスト フィールドだけでなく、スイッチ トグルを切り替えます。
いくつかのコード: AlertViewController.h
@property (weak, nonatomic) IBOutlet UITableView *table;
AlertViewController.m
@synthesize table;
static NSString *alertCellID=@"AlertViewCell";
----some code here ----
-(void)ViewDidLoad
{
---some code here----
self.table.delegate=self;
self.table.dataSource=self;
if(managedObjectContext==nil)
{
id appDelegate=(id)[[UIApplication sharedApplication] delegate];
managedObjectContext=[appDelegate managedObjectContext];
}
[self loadCategories];
[table registerNib:[UINib nibWithNibName:@"AlertViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:alertCellID];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrCategories count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Category *cat=[arrCategories objectAtIndex:indexPath.row];
AlertViewCell *cell = [tableView dequeueReusableCellWithIdentifier:alertCellID];
UILabel *lblGroupName=(UILabel *)[cell viewWithTag:101];
lblGroupName.text=cat.nameEn;
UITextField *txtHours=(UITextField *)[cell viewWithTag:103];
txtHours.delegate=self;
return cell;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
編集: 8レコードに収まるスクロールサイズに関連しているのかわかりませんか?そしてそれを克服する方法は?