![](/img/trans.png)
[英]How can I highlight the BarButton in navigation bar without tapping it?
[英]Can i set the UITableViewCellAccessoryCheckmark on BarButton?
我想在觸摸Bar按鈕時UITableViewCellAccessoryCheckmark tableView的所有單元格嗎?
您需要使用在barbutton聲明中指定的方法來設置單元格附件類型。
檢查此代碼。 那樣跟隨
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(showChecked)];
- (void)showChecked{
isChecked = YES;
[tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
return cell;
}
使用布爾變量isButtonClick;
然后在barButton上附加一個動作。
所以在點擊
-(void)click
{
isButtonClick=YES;
[yourTable reloadData];
}
現在在cellforRowAtIndexPath中
放置條件
{
//your code
if(isButtonClick)
{
[yourTable setAccessoryType:UITableViewCellAccessoryCheckmark];
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.