每當我退出一個文本框,UIActionsheet應該出現以及保存一些信息。當我退出文本字段時,程序退出,控制檯說它是一個無效的類。爲什麼這個代碼不工作?爲什麼我的班級沒有被打電話?
- (IBAction)classFieldDoneEditing:(id)sender
- (IBAction)classFieldDoneEditing:(id)sender
withActionSheet:(UIActionSheet *)typeSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
self.indicatedClass = classField.text;
NSString *greeting = [[NSString alloc]
initWithFormat:@"%@", indicatedClass];
labelClassTitle.text = greeting;
labelClassTitle.hidden = NO;
[greeting release];
[sender resignFirstResponder];
typeSheet = [[UIActionSheet alloc]
initWithTitle:@"Class types"delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"Core Class", @"Elective", nil];
[typeSheet showInView:self.view];
[typeSheet release];
if (buttonIndex == 0) {
self.indicatedClass = classField.text;
NSString *indicatedString = indicatedClass;
NSString *greeting = [[NSString alloc]
initWithFormat:@"%@ meets 6 times per rotation", indicatedString];
labelClassTitle.text = greeting;
labelClassTitle.hidden = NO;
[greeting release];
[indicatedClass release];
}
else if (buttonIndex == 1) {
self.indicatedClass = classField.text;
NSString *indicatedString = indicatedClass;
NSString *greeting = [[NSString alloc]
initWithFormat:@"%@ meets 3 times per rotation", indicatedString];
labelClassTitle.text = greeting;
labelClassTitle.hidden = NO;
[greeting release];
[indicatedClass release];
}
}
我已經鏈接了它 – mentorship 2012-03-06 14:51:51