2012-05-29 70 views
0

我在刷卡时试图改变视图。我有滑动工作查找,因为我已经通过更改背景色测试了这一点。如何从笔尖加载uiview

从那时起,我添加了一个新的view.nib,并将该类设置为与当前视图相同。 这个类.h文件中我已经这样做了

@interface MasterViewController : UIViewController <UIGestureRecognizerDelegate>{ 

    UIView *myView; 
    UIView *secondView; 
} 

@property (strong, nonatomic) IBOutlet UIView *myView; // attached to Viewcontroller nib 
@property (strong, nonatomic) IBOutlet UIView *secondView; // attached to the secondView 


- (void)swipedScreen; 

MyView的内部是第一次出现,secondView的是,我已经创建并改变了它的类涉及到这一观点笔尖的视图主视图。

从那里我已经在.m文件

- (void) setupSwipeGestureRecognizer { 
    UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedScreen)]; 
    swipeGesture.direction = (UISwipeGestureRecognizerDirectionRight|UISwipeGestureRecognizerDirectionLeft); 
    [myView addGestureRecognizer:swipeGesture]; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
    self.title = @"Prototype"; 
    [self setupSwipeGestureRecognizer]; 
} 

- (void)swipedScreen 
{ 
    // Not sure what to do here. 
    [[NSBundle mainBundle] loadNibNamed:@"SecondView" owner:self options:nil]; 

} 

我只是不知道在swipedScreen方法做的就是secondView出现这样做..我想动画这个观点在下滑从正确的角度来看......但是现在这只是次要的事实上只是让视图出现......不知道我在这里做错了什么,但显然它是一些非常基本的东西。

任何帮助将不胜感激。

+0

那么,只需使用动画来改变你的'secondView'位置动画,当它在正确的位置时,隐藏'myView'。这不是最好的解决方案,但解决你的问题。 – 2012-05-29 01:33:44

+0

谢谢..希望有更多优雅的东西..感谢您的建议,但我会牢记在心。 –

+0

好吧,如果您没有其他解决方案,那就是一个备份计划。 :-) – 2012-05-29 01:36:14

回答

0

正如我说:

- (void)swipedScreen 
{ 
    [UIView animateWithDuration:3.0f delay:0 options:UIViewAnimationOptionCurveLinear 
       animations:^{ 
         secondView.frame = CGRectMake(180, secondView.frame.origin.y, secondView.frame.size.width, secondView.frame.size.height); 
        } 
       completion:^(BOOL finished){ 
         myView.hidden = YES; 
       }]; 
} 

其实,你就必须改变X,Y,宽度和高度值要进行动画处理,而当它完成了,我设置的主视图 - myView - 隐藏。