快要疯了用的UITextField输入我有一个用下面的代码引发了PromoCodeViewController:在一个非常简单的应用程序
@implementation Demo_WebServiceCallingUsingiOSAppDelegate
@synthesize window = _window,promoCodeController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.promoCodeController = [[PromoCodeViewController alloc] init];
[self.window addSubview:self.promoCodeController.view];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
的PromoCodeViewController包含的UITextField和我落实UITextFieldDelegate为PromoCodeViewController如图所示:
@interface PromoCodeViewController : UIViewController<UITextFieldDelegate>
{
IBOutlet UITextField *promoCodeTextField;
}
@property (nonatomic,retain) IBOutlet UITextField *promoCodeTextField;
@end
我实现textFieldShouldReturn方法如下所示:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
return TRUE;
}
我甚至已经将PromoCodeViewController设置为UITextField事件的委托。当我开始在TextBox中输入时,它会抛出“Program received signal。EXC_BAD_ACCESS”。当我在UITextField中输入第二个字符时会发生这种情况。我究竟做错了什么?
更新1:
的错误出现在以下部分:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([Demo_WebServiceCallingUsingiOSAppDelegate class]));
}
}
,我不认为你应该你的窗口在第一个代码块被设置为你promoCodeViewController ......虽然我不认为这是什么原因造成的错误。 –
什么是崩溃时的堆栈跟踪? – sergio
@sergio栈跟踪没有任何东西! – azamsharp