按UIImage打开新的视图控制器

时间:2014-11-26 10:13:45

标签: ios objective-c xcode ipad uiimage

我有以下代码,并且想要在按下图像1,2或3时打开特定的视图控制器。请您提供一个示例代码来完成此任务。谢谢

UIImage *startImage = [UIImage imageNamed:@"start"];
    UIImage *image1 = [UIImage imageNamed:@"icon-demo1"];
    UIImage *image2 = [UIImage imageNamed:@"icon-demo2"];
    UIImage *image3 = [UIImage imageNamed:@"icon-demo3"];
    NSArray *images = @[image1, image2, image3];
    SphereMenu *sphereMenu = [[SphereMenu alloc] initWithStartPoint:CGPointMake(160, 320)
                                                         startImage:startImage
                                                      submenuImages:images];

3 个答案:

答案 0 :(得分:3)

您应该实施SphereMenuDelegate协议和
- (void)sphereDidSelected:(int)index;方法

      sphereMenu.delegate = self;    

//...
- (void)sphereDidSelected:(int)index
{
    switch (index) {
        case 0:
            // image1 selected
            break;
        case 1:
            // image2 selected
            break;
        case 2:
            // image3 selected
            break;
    }
}

答案 1 :(得分:0)

只需拖动ViewController上的三个按钮(在storyboard中)设置图像按钮即可。 拖放segue三个按钮到三个ViewControllers。

答案 2 :(得分:0)

实施SphereMenuDelegate delegate并复制该方法

  func sphereDidSelected(index: Int) {
    println("image Clicked")
  }

您将在该图片上获得click event