ViewController按钮按钮触摸(无NVController)

时间:2015-09-02 22:14:57

标签: ios uiviewcontroller transition

我以编程方式创建了一个按钮,并为其添加了一个选择器 (触摸)里面的触摸应该转换到下一个视图 控制器(LocationVC)之间没有navigationController。我有 在故事板中添加了第二个视图控制器并将其命名为其类 “LocationVC2。不管怎样,黑屏都没事。有什么帮助吗?

//
//  ViewController.h
//  NanCom4
//
//  Created by Daniel Habshush on 8/30/15.
//  Copyright © 2015 Daniel Habshush. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface ViewController : UIViewController

@property (nonatomic, strong) IBOutlet UIButton *circle1;

@property (nonatomic, strong) IBOutlet UIButton *circle2;

@property (nonatomic, strong) IBOutlet UIButton *circle3;
@property (nonatomic, strong) IBOutlet UIButton *circle4;
@property (nonatomic, strong) IBOutlet UIButton *circle5;


@end



- (void)viewDidLoad {
    [super viewDidLoad];

    circle1 = [[UIButton alloc] init];
    [circle1 setFrame:CGRectMake(128, 247, 100, 100)];
    [circle1 setIsAccessibilityElement:YES];

    [circle1 addTarget:self action:@selector(pressed3:) forControlEvents:UIControlEventTouchUpInside];

    circle1.backgroundColor = [UIColor clearColor];
    [circle1 setImage:[UIImage imageNamed:@"Circle6.png"] forState:UIControlStateNormal];

    [self.view addSubview:circle1];






    circle2 = [[UIButton alloc] init];
    [circle2 setFrame:CGRectMake(55, 170, 120, 120)];
    [circle2 setIsAccessibilityElement:YES];

    [circle2 addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchUpInside];

    circle2.backgroundColor = [UIColor clearColor];

    [circle2 setTitle:@"Orit" forState:UIControlStateNormal];
     [circle2 setBackgroundImage: [UIImage imageNamed:@"pie2.png"] forState:UIControlStateNormal];

    [self.view addSubview:circle2];





    circle3 = [[UIButton alloc] init];
    [circle3 setFrame:CGRectMake(55, 300, 120, 120)];

    [circle3 setIsAccessibilityElement:YES];
    [circle3 setAlpha:0];

       circle3.backgroundColor = [UIColor clearColor];
    [circle3 setTitle:@"DANI" forState:UIControlStateNormal];

    [circle3 setBackgroundImage: [UIImage imageNamed:@"pie3.png"] forState:UIControlStateNormal];

    [self.view addSubview:circle3];




    circle4 = [[UIButton alloc] init];
    [circle4 setFrame:CGRectMake(185, 300, 120, 120)];

    [circle4 setIsAccessibilityElement:YES];
    [circle4 setAlpha:0];

    circle4.backgroundColor = [UIColor clearColor];
    [circle4 setTitle:@"DANI" forState:UIControlStateNormal];

    [circle4 setBackgroundImage: [UIImage imageNamed:@"pie5.png"] forState:UIControlStateNormal];

    [self.view addSubview:circle4];




    circle5 = [[UIButton alloc] init];
    [circle5 setFrame:CGRectMake(185, 170, 120, 120)];

    [circle5 setIsAccessibilityElement:YES];
    [circle5 setAlpha:0];

       circle5.backgroundColor = [UIColor clearColor];

    [circle5 setTitle:@"DANI" forState:UIControlStateNormal];

    [circle5 setBackgroundImage: [UIImage imageNamed:@"pie4.png"] forState:UIControlStateNormal];
    [self.view addSubview:circle5];

}




- (void)pressed3:(UIButton*)sender  {

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.5];
    [UIView setAnimationDelay:0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];

    self.circle1.alpha = 0.2;



    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0];
    [UIView setAnimationDelay:0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];

    self.circle2.alpha = 1;



    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationDelay:0.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];

    self.circle3.alpha = 1;

    [UIView commitAnimations];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationDelay:0.5];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];


    self.circle4.alpha = 1;

    [UIView commitAnimations];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationDelay:0.75];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
    self.circle5.alpha = 1;

    [UIView commitAnimations];
}

- (void)touch:(id)sender
{

        LocationVC *newVC = [LocationVC new];
        [self presentViewController:newVC animated:YES completion:nil];

    }


@end

0 个答案:

没有答案