-3

在我的应用程序中,我有 4 个 UI 按钮。单击显示子视图视图的每个按钮都包含学习和播放选项。单击时,想要显示不同的视图取决于 uibutton 选择。这是我的代码。请帮我在点击选项上执行不同的视图。

-(IBAction)animals
{
  //UIAlertView *alert4=[[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:@"LEARN",@"PLAY",@"CANCEL",nil];
//alert4.tag = 4;  
//[alert4 show];///when it was in uialert view

CGPoint point = [tap locationInView:self.birdsbut];
pv = [PopoverView showPopoverAtPoint:point inView:movingview withContentView:alertvu delegate:self];
}
-(IBAction)birds
{

CGPoint point = [tap locationInView:self.birdsbut];
pv = [PopoverView showPopoverAtPoint:point inView:movingview withContentView:alertvu delegate:self];
}
-(IBAction)direct
{ 
 CGPoint point = [tap locationInView:self.birdsbut];
pv = [PopoverView showPopoverAtPoint:point inView:movingview withContentView:alertvu delegate:self];
}
-(IBAction)fruit
{
 CGPoint point = [tap locationInView:self.birdsbut];
pv = [PopoverView showPopoverAtPoint:point inView:movingview withContentView:alertvu delegate:self];
}

我应该添加什么,以在同一次单击中执行多视图选项?

4

1 回答 1

1

为所有按钮设置标签(唯一),然后将它们绑定到 touchUpInside 中的同一事件(IBAction)。在以下情况下,将它们全部绑定到事件动物:

 -(IBAction) animals: (id) sender;

    ===================================

    -(IBAction) animals: (id) sender {
      NSLog(@"User clicked %@", sender);
      // Do something here with the variable 'sender'
      if(sender.tag==1)
         {
           enter code here
         }
          else if (sender.tag==2)
           {
             enter code here
           }
    }
于 2012-11-14T06:58:12.860 回答