Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么单个iAction不能与xib文件中的UIButton关联?_Ios_Objective C_Uibutton_Ibaction - Fatal编程技术网

Ios 为什么单个iAction不能与xib文件中的UIButton关联?

Ios 为什么单个iAction不能与xib文件中的UIButton关联?,ios,objective-c,uibutton,ibaction,Ios,Objective C,Uibutton,Ibaction,outlet属性和iAction在UIViewController中声明。xib文件中的UILabel视图可以链接到outlet,但是当我将同一xib文件中的UILabel按钮拖动到文件所有者(已经设置了UIViewController类)时,并没有要关联的弹出窗口show iAction。添加另一个具有不同名称的iAction,当我进行相同的拖动时,第二个iAction将出现在弹出窗口中 我想知道UIViewController中是否应该声明多个iAction?为什么?我的代码如下: @int

outlet属性和iAction在UIViewController中声明。xib文件中的UILabel视图可以链接到outlet,但是当我将同一xib文件中的UILabel按钮拖动到文件所有者(已经设置了UIViewController类)时,并没有要关联的弹出窗口show iAction。添加另一个具有不同名称的iAction,当我进行相同的拖动时,第二个iAction将出现在弹出窗口中

我想知道UIViewController中是否应该声明多个iAction?为什么?我的代码如下:

@interface BNRReminderViewController()  
//this outlet is linked to an UIView successfully
@property (nonatomic, weak) IBOutlet UIDatePicker *datePicker;

@end

@implementation BNRReminderViewController:UIViewController


//doesn't appear in popup window
-(IBAction)addReminder:(id)sender
{
    NSDate *date=self.datePicker.date;
    NSLog(@"Seeting a reminder for %@", date);
}

//shows up in popup window and can be associated to a UIButton
-(IBAction)addReminder1:(id)sender
{
    NSDate *date=self.datePicker.date;
    NSLog(@"Seeting a reminder for %@", date);  
}

@end
答案是

@实现BNRREMINDERVEWCONTROLLER:UIViewController


删除基类名称可以解决此问题。

是否在头文件中声明了操作方法?正如@特洛伊敌人所指出的,如果您也发布了.h文件中的代码,这将很有帮助。有时,编译应用程序或重新启动Xcode等简单操作可以帮助您完成此类操作。@特洛伊敌人,不。它只在.m文件中。我确信没有必要在头文件中声明。我复制了另一个示例项目,其中iAction方法只在.m文件中编写,而在.h文件中没有声明,但与xib文件中的按钮关联起来效果很好。此外,最让我困惑的是,关联框中只显示AddRemember1,而AddRemembernot…这两个方法之间除了名称之外还有什么区别吗?都不在.h文件中。。。