2015-07-10 95 views
1

我在調試時遇到了問題。我有一個UITextView在碰觸時會崩潰。只有其中一些崩潰,如:帳戶類型和增值稅季度結束。 這是屏幕的外觀崩潰時,如:觸摸時UITextField崩潰

enter image description here

這是代碼:

@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

崩潰的消息? – Aladin

+0

根本沒有消息。這是另一件困難的事情。 – Paul

回答

-1

上的UITextView此方法崩潰上,輕觸

[ActionSheetPicker displayActionPickerWithView:self.view數據:arrAccountType的selectedIndex:self.selectedIndex目標:自我行動:@選擇(itemWasSelected :)標題:NSLocalizedString(@「Select_Account_Type 「,無)];

+0

是的,我認爲是。但爲什麼? – Paul

+0

哪個版本的ActionSheetPicker? –

+0

嘗試新版本https://github.com/skywinder/ActionSheetPicker-3.0 –

0

嘗試設置selectedIndex設置爲0第一:

[ActionSheetPicker displayActionPickerWithView:self.view data:arrAccountType selectedIndex:0 target:self action:@selector(itemWasSelected:) title: NSLocalizedString(@"Select_Account_Type", nil) ]; 
+0

對不起,它沒有工作。 – Paul