1. 如上图一个 UITableView 被重复插入两个图, 请看代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | - (UITableViewCell *)tableView:(UITableView *)tableview cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *TableSampleIdentifier = @ "TableSampleIdentifier" ; UITableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:TableSampleIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TableSampleIdentifier]; } cell.selectionStyle = UITableViewCellSeparatorStyleNone; NSUInteger row = [indexPath row]; NSUInteger section = [indexPath section]; horizontalLinesProperties=nil; anchorPropertiesArray=nil; yValuesArray = nil; xValuesArray = nil; xTitlesArray = nil; xProperty = nil; yProperty = nil; verticalLinesProperties = nil; NSArray *line1 = [[NSArray alloc]initWithObjects: @ "10000" ,@ "21000" ,@ "24000" ,@ "11000" ,@ "5000" ,@ "2000" ,@ "9000" ,@ "4000" ,@ "10000" ,@ "17000" ,@ "15000" ,@ "11000" ,nil]; NSArray *line2 = [[NSArray alloc]initWithObjects: @ "Jan" ,@ "Feb" ,@ "Mar" ,@ "Apr" ,@ "May" ,@ "Jun" ,@ "Jul" ,@ "Aug" ,@ "Sep" ,@ "Oct" ,@ "Nov" , @ "Dec" ,nil]; horizontalLinesProperties=[NSDictionary dictionaryWithObjectsAndKeys:@ "1,2" ,@ "dotted" , nil]; verticalLinesProperties=[NSDictionary dictionaryWithObjectsAndKeys:@ "1,2" ,@ "dotted" , nil]; yValuesArray = line1; xValuesArray = line2; xTitlesArray = line2; mLineGraph=[[MIMLineGraph alloc]initWithFrame:CGRectMake(5, 5, 310, 150)]; mLineGraph.delegate=self; mLineGraph.titleLabel.text = nil; mLineGraph.mbackgroundColor=[MIMColorClass colorWithComponent:@ "1,1,1" ]; mLineGraph.anchorTypeArray=[NSArray arrayWithObjects:[NSNumber numberWithInt:NONE], nil]; MIMColorClass *c1=[MIMColorClass colorWithComponent:@ "0,169,249" ]; mLineGraph.lineColorArray=[NSArray arrayWithObjects:c1, nil]; mLineGraph.xTitleStyle=X_TITLES_STYLE1; mLineGraph.leftMargin = -15; mLineGraph.rightMargin = 6; mLineGraph.topMargin = 10; mLineGraph.bottomMargin= -60; [mLineGraph drawMIMLineGraph]; switch (section) { case 0: [cell.contentView addSubview:mLineGraph]; break ; case 2: [cell.contentView addSubview:mWallGraph]; break ; default : break ; } return cell; } |
上面的图很明显被插入了两张图, 我通过 NSlog来打印 log 发现执行得并没有错误, 但是同一个 Cell 被插入两张图, 不知为何? 求解
标签: iOS Objective-C