이 문제를 2 일 동안 처리하려고했습니다. 내 응용 프로그램에는 텍스트 필드와 버튼이 있습니다. 텍스트 필드가 비어있을 때 버튼을 누르면 안정된 작동이되고 버튼을 누르면 경고 메시지가 나타납니다. 그러나 텍스트 입력란에 무언가를 입력하고 버튼을 누르면 충돌이 발생합니다. 디버그 콘솔에서 볼 수있는 것 : "프로그램 수신 신호 :"EXC_BAD_ACCESS "." 스택 세부 정보 등이 없습니다. 내 관련 코드 : 헤더 파일 :"프로그램 수신 신호 :"EXC_BAD_ACCESS "로 인해 버튼 동작을 처리 할 수 없습니다."
는#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
------하는 .m 파일 :
#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
.Xib 파일의 일부 세부 사항 : 조치 방법은 "터치 업 내부"를 통해 파일 소유자에게 첨부됩니다. 텍스트 필드에 연결되어있는 콘센트가 있습니다 (텍스트도 인쇄되었으므로 잘 동작합니다.) 또한 txt를 입력하는 동안보기를 두드리는 이벤트를 지원할 수 있도록 UICpntrol로보기의 클래스 ID를 변경했습니다. 텍스트 필드에서 키보드가 종료됩니다 ...
무엇이 잘못 되었나요?