申し訳ありません、これはiPhone開発の初心者なので簡単な修正です。私の代理人でiPhone開発のEXC_BAD_ACCESS
、作成したプロファイルのボタンを押した後、作成したプロファイルビューがプッシュされる:
-(void) createProfile_clicked:(id)sender
{
AddNewProfile *create = [[AddNewProfile alloc] init];
[self.window addSubview:create.view];
[self invisibleCreateProfileBar];
AddNewProfile *controller = [[AddNewProfile alloc] initWithNibName:@"AddNewProfile" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:controller animated:YES ];
currentController=controller;
}
を次にAddNewProfile.mに:
- (IBAction)backgroundTap:(id)sender {
if([nameField isFirstResponder]){
[nameField resignFirstResponder];
}
if([ageField isFirstResponder]){
[ageField resignFirstResponder];
}
if([doctorNameField isFirstResponder]){
[doctorNameField isFirstResponder];
}
if([doctorNumberField isFirstResponder]){
[doctorNumberField resignFirstResponder];
}
}
これは、すべてのEXC_BAD_ACCESSエラーにつながりますFirstResponderが私のコントロールのいずれかと一緒にいたずらされた時間。私はコントロール(テキストボックス)を選択することができますが、一度クリックするとクラッシュします。
ご協力いただければ幸いです。
フィールドを保持する必要がありますか?皆さんはもっとコードを必要としていますか?申し訳ありませんが、私はこのすべてに本当に新しいです。 :/
EDIT:
#import "AddNewProfile.h"
#import "BIDDailyMedsAppDelegate.h"
#import "BIDDailyMedsAppDelegate.h"
@implementation AddNewProfile
@synthesize nameField;
@synthesize ageField;
@synthesize doctorNameField;
@synthesize doctorNumberField;
@synthesize saveButton;
@synthesize sexField;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
//[nameField becomeFirstResponder];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[self setNameField:nil];
[self setAgeField:nil];
[self setDoctorNameField:nil];
[self setDoctorNumberField:nil];
[self setSaveButton:nil];
[self setSexField:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (IBAction)pressSave:(id)sender {
BIDDailyMedsAppDelegate *appDelegate =
[[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context =
[appDelegate managedObjectContext];
NSManagedObject *newContact;
newContact = [NSEntityDescription
insertNewObjectForEntityForName:@"Profiles"
inManagedObjectContext:context];
[newContact setValue:self.nameField.text forKey:@"name"];
[newContact setValue:self.ageField.text forKey:@"age"];
if(self.sexField.selected==0){
[newContact setValue:@"YES" forKey:@"male"];
}else{
[newContact setValue:@"NO" forKey:@"male"];
}
[newContact setValue:self.doctorNameField.text forKey:@"doctorName"];
[newContact setValue:self.doctorNumberField.text forKey:@"doctorPhone"];
NSError *error;
[context save:&error];
//Pop view off stack
// locally store the navigation controller since
// self.navigationController will be nil once we are popped
UINavigationController *navController = self.navigationController;
// Pop this controller and replace with another
[navController popToRootViewControllerAnimated:YES];
//UIViewController *rootController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
//[navController pushViewController:rootController animated:YES];
}
- (IBAction)backgroundTap:(id)sender {
//AppDelegate = [[UIApplication sharedApplication] delegate];
//[AppDelegate clearCreateProfileFields];
//UITextField *currentTextField=sender;
//[currentTextField resignFirstResponder];
[self.view endEditing: YES];
}
@end
ブレークポイントを入れてお知らせくださいあなたがEXC_BAD_ACCESSを与える行を正確に示します。そうでなければ、他の人から無作為に仮定された答えが得られます。 –
したがって、私は打撃されないbagroundTapを含むすべての関数の始めにブレークポイントを置きます。どのようなブレークポイントがそのファイルに入っているかわからないのですか? – gkres121