我的应用程序曾用于ios5到ios7。最近我尝试使用xcode6和simulator8在ios8上运行。该应用程序崩溃了。我发现异常" NSInvalidArgumentException,原因 - [UILabel selectedSegmentIndex]无法识别的选择器发送到实例"当它达到[[self weightUnitsc_s] setSelectedSegmentIndex:0];
时- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
tableView.separatorColor=[UIColor colorWithRed:0 green:0.5765 blue:0.4431 alpha:1];
static NSString *CellIdentifier = @"Cell";
//UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (indexPath.section==0){
if (indexPath.row==0){
weight * cell=(weight *)[tableView dequeueReusableCellWithIdentifier:@"weightcell"];
if (cell == nil) {
NSLog(@"weight nil");
NSArray* arr=[[NSBundle mainBundle] loadNibNamed:@"weight" owner:self options:nil];
cell= [arr objectAtIndex:0];
[[cell weightUnitsc] setFrame:CGRectMake(cell.weightUnitsc.frame.origin.x, cell.weightUnitsc.frame.origin.y+5, cell.weightUnitsc.frame.size.width, 30)];
[[cell weightUnitsc] addTarget:self action:@selector(segChange2) forControlEvents:UIControlEventValueChanged];
}
[cell LabelText:[Language get:@"setting.weightUnit" alter:@""]];
[cell SegText:[Language get:@"setting.weightUnit.kg" alter:@""] :0];
[cell SegText:[Language get:@"setting.weightUnit.g" alter:@""] :1];
[cell SegText:[Language get:@"setting.weightUnit.lbs" alter:@""] :2];
[cell SegText:[Language get:@"setting.weightUnit.oz" alter:@""] :3];
[self setWeightUnitsc_s:[cell.contentView.subviews objectAtIndex:1]];
switch ([WeightUnit getCurrentWeightID]) {
case 1:
[[self weightUnitsc_s] setSelectedSegmentIndex:1];
break;
case 2:
[[self weightUnitsc_s] setSelectedSegmentIndex:2];
break;
case 3:
[[self weightUnitsc_s] setSelectedSegmentIndex:3];
break;
default:
[[self weightUnitsc_s] setSelectedSegmentIndex:0];
break;
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;
[cell setBackgroundView:[[[UACellBackgroundView alloc] init] autorelease]];
[(UACellBackgroundView *)[cell backgroundView] setPosition:UACellBackgroundViewPositionTop];
return cell;
}
有人可以帮忙解释并解决问题吗?谢谢。