我在调试时遇到问题。我有一个触摸时崩溃的UITextView。其中只有一部分崩溃如:账户类型和增值税季度结束。 这是崩溃时屏幕的样子:
这是代码:
@synthesize txtAccType = _txtAccountType;
- (void)viewDidLoad {
[super viewDidLoad];
arrAccountType = [[NSMutableArray alloc] initWithObjects:@"Freelancers", nil];
//self.title = @"Account Setting";
self.title = NSLocalizedString(@"AccountSetting", nil);
self.navigationItem.rightBarButtonItem = self.doneBarButtonItem;
arrCatId = [[NSMutableArray alloc] init];
arrCategory = [[NSMutableArray alloc] init];
arrTotal = [[NSMutableArray alloc] init];
tag = 0;
[svAccountSetting setContentSize:CGSizeMake(280, 600)];
arrCsvData = [[NSMutableArray alloc] init];
quarterEndDatesArray = [[NSArray alloc] initWithObjects:
@"April/Jul/Oct/Jan",
@"May/Aug/Nov/Feb",
@"June/Sep/Dec/Mar", nil];
[self setAcc];
}
-(IBAction)selectAccountType
{
[self.txtAccType resignFirstResponder];
[svAccountSetting setContentOffset:CGPointMake(0, 6) animated:YES];
[ActionSheetPicker displayActionPickerWithView:self.view data:arrAccountType selectedIndex:self.selectedIndex target:self action:@selector(itemWasSelected:) title: NSLocalizedString(@"Select_Account_Type", nil) ];
}
- (void)itemWasSelected:(NSNumber *)selectedIndexs {
//Selection was made
self.selectedIndex = [selectedIndexs intValue];
self.txtAccType.text = [arrAccountType objectAtIndex:self.selectedIndex];
}
由于这个项目较旧,我想知道一些经验丰富的iOS开发人员是否能够提供帮助。
答案 0 :(得分:0)
首先尝试将selectedIndex设置为0:
[ActionSheetPicker displayActionPickerWithView:self.view data:arrAccountType selectedIndex:0 target:self action:@selector(itemWasSelected:) title: NSLocalizedString(@"Select_Account_Type", nil) ];
答案 1 :(得分:-1)
此方法在触摸UITextView时崩溃
[ActionSheetPicker displayActionPickerWithView:self.view data:arrAccountType selectedIndex:self.selectedIndex target:self action:@selector(itemWasSelected :) title:NSLocalizedString(@" Select_Account_Type",nil)];