English 中文(简体)
由于“Program”收到信号,“EXC_BAD_ACCESS”
原标题:Can t handle button action due to "Program received signal: “EXC_BAD_ACCESS”."

Tried to deal with this problem for two days now. My app has a text field and a button. when the text field is empty, pressing the button gives me a stable run and i receive an alert after pressing the button. However, if i am typing something in the text field, then pressing the button - it crashes. All i can see in the debug console is: "Program received signal: “EXC_BAD_ACCESS”." There is no stack detail or anything. My relevant code: the header file:

#import <UIKit/UIKit.h>

@interface SpyTextViewController : UIViewController {

    int sliderSpeed;
    IBOutlet    UITextField     *textInput;
}

@property (nonatomic, retain) IBOutlet UITextField *textInput;




- (IBAction)sliderChanged:(id)sender;//speed of text show changed

- (IBAction)textFieldDoneEditing:(id)sender;//dor  DONE  on keyboard
- (IBAction)backgroundTap:(id)sender;//for handling tapping on background

- (IBAction)textEmButtonPressed:(id)sender;

@end

- 档案:

#import "SpyTextViewController.h"
#import "txtViewController.h"

@implementation SpyTextViewController
@synthesize textInput;






- (IBAction)sliderChanged:(id)sender
{
    UISlider *slider = (UISlider *)sender;
    sliderSpeed =  (int)(slider.value + 0.5f);//setting the speed determinned by the usr in slider
}

- (IBAction)textFieldDoneEditing:(id)sender
{
    [sender resignFirstResponder];
    NSLog(@"our text input  is %@", textInput.text);
}

- (IBAction)backgroundTap:(id)sender
{
    [textInput resignFirstResponder]; 
}   

- (IBAction)textEmButtonPressed:(id)sender
{
    NSLog(@"our text input length is %@", [textInput.text length]);

    /*
     if ([textInput.text length])
     {
     NSLog(@" inside the tvc init ");
     //create the sub MVC 
     txtViewController *tvc = [[txtViewController alloc] init];
     tvc.scrollSpeed = sliderSpeed;
     tvc.scrollTxt = textInput.text;
     [self.navigationController pushViewController:tvc animated:YES];
     [tvc release];
     //run text using speed;
     }
     else */
    {
        //tell  em to input text with some pop-up
        NSString *msg = nil;
        msg = @"Write text to transmit";
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Forgot something?"
                                                        message:msg
                                                       delegate:self
                                              cancelButtonTitle:@"Back" 
                                              otherButtonTitles:nil];

        [alert show]; 
        [alert release]; 
        [msg release];
    }
}

- (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.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [textInput release];
    [super dealloc];
}

@end

Some detail on the .Xib file: the action method is attached to file s owner through "touch-up inside". the text field has its outlet connected to it also (i also printed the contents of the text, it works fine).I also changed the view s class identity to be UICpntrol so i could support the event of tapping on the view while typing txt in the text field so that the keyboard will be exited...

什么是错了?

问题回答

鞭str是固定的,释放可能造成例外。

在挖土机下运行(“Build和Debug”)。

夸大窗口(轮式-Y)将显示问题发生地的追溯,让你在此刻审查变数。





相关问题
setOrientation problem

I have a really strange orientation issue. I have a sequence of view controllers under a navigation controller. One of them can take any orientation. When I m leaving the orientation I have to use ...

Weak linking with Interface Builder

The application uses a 3.x SDK feature, but it needs to run in 2.x devices. The solution seems to be using "weak linking", which I did, but the app still fails to compile for iPhone 2.2.1: &...

Toolbar items in sub-nib

This question has probably been asked before, but my google-fu must be inferior to everybody else s, cause I can t figure this out. I m playing around with the iPhone SDK, and I m building a concept ...

PNG transparency in Interface Builder

I m adding an Image View in Interface Builder with a transparent PNG (A logo in the Navigation Bar) but the transparent pixels seems to render as white.. I searched for PNG in Interface Builder but ...

热门标签