我的ViewController
包含一个子视图:
subUIView
位于( NameSubViewController
class with XIB)。
子视图包含一个UITextField
.
我添加了这个动作:
- (IBAction)textFieldReturn:(id)sender;
在NameSubViewController
课堂上并将其连接到 XIB 中文件所有者的文本字段(退出时结束)。
但是当我点击返回时,日志会给我一条错误消息,并且模拟器中没有任何反应。
这是相关代码:
视图控制器.h:
@property (nonatomic, strong) UIView *nameSubView;
ViewController.m (viewDidLoad):
UIViewController *nameController = [[NameSubViewController alloc] initWithNibName:@"NameSubViewController" bundle:nil];
nameSubView = [nameController view];
[self.view addSubview:nameSubView];
NameSubViewController.h:
#import <UIKit/UIKit.h>
@interface NameSubViewController : UIViewController
@property (nonatomic, strong) IBOutlet UITextField *textField;
- (IBAction)textFieldReturn:(id)sender;
//Not working.. Connected from files owner to textField with option didEndOnExit
NameSubViewController.m:
-(IBAction)textFieldReturn:(id)sender
{
[sender resignFirstResponder];
}
当我点击返回时,我在日志中收到此消息:
AppName[6656:f803] -[CALayer textFieldReturn:]: unrecognized selector sent to instance 0x6e99d40
2012-08-28 02:51:26.954 AppName[6656:f803] *** WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: <NSInvalidArgumentException> -[CALayer textFieldReturn:]: unrecognized selector sent to instance 0x6e99d40
并且键盘不会被解雇。什么可能导致我的问题?
视图控制器:
http://www.flickr.com/photos/80427098@N07/7877111708/in/photostream
NameSubViewController,在 ViewController 的 subView 中显示的视图:
http://www.flickr.com/photos/80427098@N07/7877111596/in/photostream