所以我想要做的是这个视图是让我可以上下滑动UIView(menuView)进出屏幕。所以在故事板/ IB中,我放置了一个UIView并将其连接到文件所有者和所有爵士乐。然后我进入程序的下面的代码。问题是当nib加载它时,并没有把UIView放在应该放在第一位的地方,然后滑动不起作用。我试过用这个按钮编程的方法,它工作正常。预先感谢您对此有任何帮助。可滑动的UIView菜单,响应UIGestureRecognizer
.h文件中
UIView *menuView;
}
@property (strong, nonatomic) IBOutlet UIView *menuView;
.m文件
@synthesize menuView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
[swipeGesture setDirection:UISwipeGestureRecognizerDirectionDown];
[self.view addGestureRecognizer:swipeGesture];
menuView = [[UIView alloc] initWithFrame:CGRectMake(0, -80, 320, 80)];
[menuView setFrame:CGRectMake(0, -80, 320, 80)];
[self.view addSubview:menuView];
}
-(void)swipe:(UISwipeGestureRecognizer*)sender {
[UIView animateWithDuration:0.5 animations:^{
[menuView setFrame:CGRectMake(0, 0, 320, 80)];
}];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
没有任何工作。 “菜单视图”仍然不会像编程时那样滑动。 – nfoggia 2012-07-27 05:58:17