开发中遇到的问题
来源:互联网 发布:如何把淘宝微信群做大 编辑:程序博客网 时间:2024/05/01 22:33
7.6私人订制
1.UITableViewCell点击不能正常获取
//正确代码-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *identifier = @"tavleViewCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; UIImageView *selectImage = [[UIImageView alloc] initWithFrame:CGRectMake(18*UIRate, (CELLHEIGHT - 12*UIRate)/2 , 12*UIRate, 12*UIRate)]; selectImage.tag = 10000; [cell.contentView addSubview:selectImage]; UILabel *typeLabel = [[UILabel alloc] initWithFrame:CGRectMake(45*UIRate, 0, WIDTH - 45*UIRate, CELLHEIGHT)]; typeLabel.tag = 10001; typeLabel.font = IOS7_Font(15*UIRate); typeLabel.textColor = UIColorFromRGB(0x2f2f2f); [cell.contentView addSubview:typeLabel]; } UIImageView *selectImage = (UIImageView *)[cell viewWithTag:10000]; UILabel *typeLabel = (UILabel *)[cell viewWithTag:10001]; typeLabel.text = [[_mDataArray objectAtIndex:indexPath.row] objectForKey:@"pay_name"]; if ((int)indexPath.row == selectInt) { selectImage.image = [UIImage imageNamed:@"PT_selected_blue_round"]; }else { selectImage.image = [UIImage imageNamed:@"PT_unselected_blue_round"]; } return cell;}
问题分析:为了给selectImage,typeLabel赋值,我把他俩定义成了全局变量,而他俩只是依附于cell的,并不是整个View,所以导致一些未知错误,正确做法应该是1、cell 单拿出来写2、用tag在cell中获取他们并赋值。
2.
0 0
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- NOTES开发中遇到的问题
- Java 开发中遇到的乱码问题
- Java 开发中遇到的乱码问题
- Java 开发中遇到的乱码问题
- 软件开发中遇到的一些问题
- Java 开发中遇到的乱码问题
- Java 开发中遇到的乱码问题
- 申请自考学士学位终于不再参加一年一次的全省申请学士学位外语统一考试了.
- AOP编程之前置通知
- HDU 4910 / BC 3D Problem about GCD
- #1039 : 字符消除
- HDU 1879 继续畅通工程
- 开发中遇到的问题
- Codeforces Round #355 (Div. 2)E. Vanya and Balloons
- android6.0 wifi连接
- matlab中关于pushbotton的左键双击响应问题
- LeetCode刷题之路 - number 26 and number 9
- iOS中常用的几何方法
- 字符集的前世今生
- 1013 Problem M
- 通过 脚本执行 kettle 的作业 命令