多视图,多视图的相同子视图

时间:2012-11-14 06:34:40

标签: iphone ios uibutton

在我的应用程序中,我有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];
}

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

1 个答案:

答案 0 :(得分: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
           }
    }