私がする必要があるのは、特定のセクション番号とその行番号を uitableview で取得する方法だけです...主にテーブルには20個のセクションが含まれています。
前もって感謝します
私がする必要があるのは、特定のセクション番号とその行番号を uitableview で取得する方法だけです...主にテーブルには20個のセクションが含まれています。
前もって感謝します
メソッドを実装しtableView:didSelectRowAtIndexPath:
ます。NSIndexPath
引数には、アクセス可能なandsection
プロパティrow
があります。
選択された indexPath: を検索し、選択された行を取得し、選択されたセクションを取得するためNSIndexPath *selectedRowIndexPath = [self.tableview indexPathForSelectedRow];
に使用します。NSUInteger selectedRow = selectedRowIndexPath.row;
NSUInteger selectedSection = selectedRowIndexPath.section;
このようにしてみて、
didSelectRowAtIndexPath メソッドで値を取得しています。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(%@"%d", indexPath.row);
NSLog(%@"%d", indexPath.section);
}
特定のセクションの行数を取得するには、次に使用します
[tableView numberOfRowsInSection:indexPath.section];
編集:-
UITableViewCell* cell = (UITableViewCell*)button.superview;
ここで選択したセルを取得し、このセルを使用してラベルの値を変更できます。
ボタンをクリックしたときにインデックスパス値を取得するには、次のコード行を使用します。
NSIndexPath *indexPath = [yourtableviewname indexPathForCell:(UITableViewCell *)sender.superview];
NSLog(@"%d",indexPath.row);
埋め込む
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int row=indexPath.row;
int section=indexPath.section
}
ユーザーが行をタップしたとき
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//section:
NSInteger section = indexpath.section
//row:
NSinteger row= indexpath.row
}
と呼ばれます。