私がしようとしていたこと - 私はUITableView
. 特定の行を選択すると、 selectionColor(Blue など) が表示されてから消えます。これを行うためのプロパティ/コードはありますか? 私は実際に MyCalender ビューで申請しています。
5 に答える
使用できます[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
あなたの -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
メソッドで。
これについては、テーブルビューでデリゲートとデータソースを参照する必要があります
データソースは入力をテーブルに設定します
デリゲートは、 tableview でのアクションのコールバックを提供します。
したがって、デリゲートメソッドを記述し、それをclassdef UITableViewDelegateに含め、xibに接続します
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
このデリゲート メソッドは、特定の行をクリックすると呼び出されます。特定の行は、「indexpath」の行であり、最終的にコードの選択を解除するこの行を含めます。
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableView を使用していて、UITableViewCell の選択を削除したい場合。次に、以下のコードを使用して、テーブルビュー セルの選択を解除する必要があります。
[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
これをあなたに追加します - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
`
UIView *violetColor = [[[UIView alloc] init] autorelease];
//violetColor.backgroundColor = [UIColor colorWithRed:0.824 green:0.749 blue:0.553 alpha:0.70];
violetColor.backgroundColor = [UIColor colorWithRed:0.724 green:0.749 blue:0.953 alpha:0.70];
cell.selectedBackgroundView = violetColor;
`
そして、これを didselect に追加します `
if (indexPath != nil) {
[mTableView deselectRowAtIndexPath:indexPath animated:YES];
}
`.i hope this will do the trick.
デリゲート メソッド didSelectRowAtndexPath では、このコードを使用します
[tableView deselectRowAtIndexPath:indexPath animated:YES];