让cell默认选中第一行

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    // 自定义cell点击背景

    cell.selectedBackgroundView =

    [[UIViewalloc] initWithFrame:cell.frame];

    cell.selectedBackgroundView.backgroundColor = RGBCOLOR(194, 194, 194);

    

// 默认选中第一行 只执行一次(否则有BUG)

    if (!isRuned) {

        NSIndexPath *firstPath = [NSIndexPathindexPathForRow:0inSection:0];

        [m_tableViewselectRowAtIndexPath:firstPath animated:YESscrollPosition:UITableViewScrollPositionTop];

        

        isRuned = YES;

    }

时间: 2024-08-03 01:18:30

让cell默认选中第一行的相关文章

【坑】tableView cell默认选中

在tableView展示的过程时候,如果想一开始就有一些cell默认被选中,不能在cellForRowAtIndexPath中cell.selected=YES, 必须在willDisplayCell中设cell.selected = YES; 相当坑比. 原文地址:https://www.cnblogs.com/yibinpan/p/9106395.html

UITableView默认选中第一行

//如果有数据,选中第一行 if(tableDataSource.count > 0) { NSIndexPath *indextPath = [NSIndexPath indexPathForRow:0 inSection:0]; // 调用UItableViewDelegate [self tableView:self.selectDeptTable didSelectRowAtIndexPath:indextPath]; // 选中第一行 [self.tableView selectRow

tableview默认选中第一行

 // 默认选中第一行只执行一次(否则有BUG)     if (!isRuned) {         NSIndexPath *firstPath = [NSIndexPathindexPathForRow:0inSection:0];         [m_tableViewselectRowAtIndexPath:firstPath animated:YESscrollPosition:UITableViewScrollPositionTop];                  isR

设置cell选中颜色以及表格默认选中某行

1.在加载cell的地方(即 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath里面)加上下面几句代码 [cell setBackgroundColor:CLEARCOLOR]; cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame]; cell.selecte

easyui tree 默认选中第一个元素

系统采用ajax异步调用后端接口做数据呈现,有个场景就是加载的树形菜单默认选中第一行,网上有人分享的解决方案能实现效果(http://aokunsang.iteye.com/blog/1489204),不过还是沿用自身提供的事件来实现这个需求. onLoadSuccess: function (node, data) { if (data.length > 0) { //找到第一个元素 var n = $('#menuTree').tree('find', data[0].id); //调用选中

ivie表格table默认展开第一行

一.效果 二.代码 <div class="tableWra"> <ticket-info-table check-type="checkQuery" :card-cancel-info="orderList"></ticket-info-table> </div> data() { return { orderList: [], } } setOrderList(true) { if (true)

iOS设置UITableView中Cell被默认选中后怎么触发didselect事件

//默认选中某个cell [self.searchResultTV selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionNone]; //实现该cell的didSelectRowAtIndexPath方法 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0

Jquery默认选中单选框radio第一个、选中指定值的单选框

概述 当页面加载时,指定区域的单选框默认选中第一个:用户勾选单选框之后,再次回到页面时,需要选中上次勾选的单选框 JS 选中指定id为"admin-content-task"中的某个radio // 页面隐藏域的值 var platIdVal = $("#platIdVal").val(); // 如果platIdVal为空,说明没有勾选单选框 if(platIdVal==null || platIdVal == ''){ // 默认选中平台单选框的第一个 $(&q

DataGridView点击空白处和失去焦点后取消选择和关闭默认选择第一行C#Winform

默认选择第一行,可以通过窗体的Load事件中调用Datagridview的ClearSelection来取消选择 也可以设置 Datagridview的CurrentCell = null; 还可以将已经选中的行的 dgv.Row[0].Selected=false; 那么如何让用户点击如图箭头所指区域 就取消选择呢? 需要在DataGridView的MouseDown或者MouseClick事件内处理 DataGridView dgv = sender as DataGridView;Data