iPhone添加(+;)按钮操作?
我已经用Xcode 4.3创建了一个主细节应用程序 在主视图中,我想在按下Add(+)按钮时向用户显示警报 我应该用哪种方法放置警报代码 任何帮助都将受到感谢。您应该创建一个iPhone添加(+;)按钮操作?,iphone,ios,xcode,master-detail,Iphone,Ios,Xcode,Master Detail,我已经用Xcode 4.3创建了一个主细节应用程序 在主视图中,我想在按下Add(+)按钮时向用户显示警报 我应该用哪种方法放置警报代码 任何帮助都将受到感谢。您应该创建一个 -(iAction)某些操作{ //显示您的警报视图 } 别忘了把它挂在IB上这个方法已经被模板创建并绑定了,所以只需像这样更改insertNewObject方法 - (void)insertNewObject:(id)sender { UIAlertView *alert = [[UIAlertView allo
-(iAction)某些操作{
//显示您的警报视图
}
别忘了把它挂在IB上这个方法已经被模板创建并绑定了,所以只需像这样更改
insertNewObject
方法
- (void)insertNewObject:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"This is an alert" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}
使用以下代码
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonActionName)];
它将在导航栏的右上角显示+
按钮
-(void) addButtonActionName {
// Your code for the Alert view
}
下面是在导航栏中添加按钮的代码
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(ShowMyAlert:)];
&这是用于事件处理的
- (void)ShowMyAlert:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Test Alert Message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
您必须在add btn action Method中写入,但我怎么知道用户何时按下了add(+)按钮?可能在这里。我现在就试试。谢谢,谢谢。捕猎者的回答对我有用。我不知道你的为什么不给我显示警报?@ivan.freire:我没有给你警报代码,但我已经告诉你在哪里写警报代码。谢谢。我确保为警报输入了正确的代码,但当我按下+,什么也没有发生。