【发布时间】:2011-08-08 23:55:35
【问题描述】:
我有以下代码,但在 NSString *weight line 处出现错误:
* 由于未捕获的异常“NSRangeException”而终止应用程序,原因:“* -[NSArray objectAtIndex:]: index 2 beyond bounds [0 .. 1]” - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
NSArray *array;
array = [[NSArray alloc]initWithObjects:@"0", @"1/2", nil];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)];
NSString *weight = [[array objectAtIndex:row] stringValue];
label.text = [NSString stringWithFormat:@"%@", weight]
【问题讨论】:
-
我已经添加了方法标题。它是一个 UIPickerView
标签: iphone objective-c