加载带有自定义转换的 XIB?

发布于 2024-11-10 05:39:23 字数 1532 浏览 3 评论 0原文

是否可以(完全)使用自定义 AnimationTransition 加载 XIB?

我所做的是创建一个“覆盖”屏幕的动画,我想要的是在该动画播放完毕后,我希望它显示新的 XIB。

我似乎找不到任何适当的解决方案......有什么想法吗?

更清楚地说:按一个按钮 -->播放动画(封面屏幕)-->加载 XIB。


又好!是的,你描述的最后一种方式就是我正在做的方式。我有两个 UIView(可能已经错了),它们被放置在每一侧的越界处(例如 x.-160.y.0 和 x.320y.0),

-(IBAction) leftDoor{

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    closeDoor1.center = CGPointMake( closeDoor1.center.x +160, closeDoor1.center.y);


    [UIView commitAnimations];

 } 


-(IBAction) rightDoor{

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    closeDoor2.center = CGPointMake( closeDoor2.center.x -160, closeDoor2.center.y);

    [UIView commitAnimations];
}

所以,我要做的不是“分割”当前视图,然后打开一个新的 XIB,我正在寻找的效果是“关门”效果,这就是我使用 UIView 的原因(我认为我将图形放在它们上面,就像两个 ImageView 一样)。然后,加载新的 XIB...这就是我真正困惑的地方。我尝试的第一种方法是创建三个 IBAction,包括上面提到的两个,然后将所有三个(多个操作)应用到一个按钮。因此,为了切换视图,我做了这样的事情: `-(IBAction) newViewDisplay:(id)sender{

theView *newViewController = [[theView alloc]
                                      initWithNibName:@"theView" bundle:nil]; 

[self.view addSubview:newViewController.view];

} 正如

你所说,这可能超出了我的能力范围,但如果我得到一些指示,我会步行数英里来完成这项工作。它确实会让我的应用程序焕然一新。非常感谢您花时间回答我的问题,祝您一切顺利/安迪

Is it possible (at all) to load a XIB with custom AnimationTransition?

What I have done, is creating an animation that "Covers" the screen, and what I want is that after that animation has done playing, I would like it to display the new XIB.

I cant seem to find any proper solution to this...Any ideas?

To be more clear: Press a button --> Play Animation (cover screen) --> Load XIB.


Hello again! Yes, the last way you described is the way I am doing it. I have two UIViews (Might be wrong already there), that are placed off-bounds on each side, (like x.-160.y.0 and x.320y.0)

-(IBAction) leftDoor{

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    closeDoor1.center = CGPointMake( closeDoor1.center.x +160, closeDoor1.center.y);


    [UIView commitAnimations];

 } 


-(IBAction) rightDoor{

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    closeDoor2.center = CGPointMake( closeDoor2.center.x -160, closeDoor2.center.y);

    [UIView commitAnimations];
}

So, what I am going to do is not to "split" the current view and then open a new XIB, the effect I am searching for is a "closing door" effect, thats why I used UIView ( thought I place graphics on top of those, like two ImageViews). Then, for loading the new XIB...This is where im really puzzled. My first way of trying this out was to make three IBActions, including the two I mentioned above, and then apply all three (multiple actions) to a button. So for switching views I did something like this: `-(IBAction) newViewDisplay:(id)sender{

theView *newViewController = [[theView alloc]
                                      initWithNibName:@"theView" bundle:nil]; 

[self.view addSubview:newViewController.view];

}
`

As you said, this might be over my head, but if I just got some directions, I´ll walk miles to make this work. It would really give my app a facelift. A huge thanks for taking time to answer my question, All the best/Andy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞笑我太脆弱 2024-11-17 05:39:23

你用什么遮住屏幕?

可以这样想,(听起来)您有 2 个视图,旧的视图和存储在该 xib 中的新的视图。动画是次要的。

您需要加载新视图,然后显示它(可以在屏幕外),然后将其设置动画(将其移动)到您想要的位置。如果你想把它分成两部分,一个在屏幕的底部,一个在屏幕的顶部,然后在中间相遇,我认为这既复杂又超出你的技能水平。 (这里并不想刻薄)。

如果您尝试按照所描述的方式制作分割动画,这是可以完成的,但您需要“伪造它”。它将涉及拍摄“屏幕截图”(某种形式)、分割它、移动这两个图像以使它们与动画相遇、加载下面的视图,然后删除图像。棘手的事情。

有必要制作这样的动画吗?

如果您可以发布您拥有的代码,我可以为您重新排列并添加它。

不过,您需要澄清您到底想做什么。

更新 3:我添加了另一个自动反转选项。

//您可以将两扇门添加到一个动画块中。

    //Create an animation block. Ease Out is better for this animation but you can change it.
[UIView animateWithDuration:1.0 delay:0.0 options:(UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAutoreverse) animations:^{
    closeDoor1.center = CGPointMake( closeDoor1.center.x +160, closeDoor1.center.y);
    closeDoor2.center = CGPointMake( closeDoor2.center.x -160, closeDoor2.center.y);

}completion:^(BOOL finished){
    if (finished) {
            //When finished, create the VC if it doesn't exist, and insert it below the 'closed door'.

        if (newViewController == nil) {
            UIViewController *newViewController = [[UIViewController alloc] initWithNibName:@"theView" bundle:nil]; 
        }

        [self.view insertSubview:newViewController.view belowSubview: closeDoor2];;
        [self.closeDoor1 removeFromSuperview];
        [self.closeDoor2 removeFromSuperview];

    }
}];

What are you covering the screen with?

Think of it this way, (it sounds like) you have 2 views, the old one and the new one that is stored in this xib. The animation is secondary.

You need to load the new view, then display it (can be off-screen), then animate it (move it) into the place you want it to go. If you want to split it into two parts, one at the bottom and one at the top of the screen, then meet in the middle, I think that's both complicated and above you skill level. (Not trying to be mean here).

If you are trying to do a split animation as described, it can be done, but you need to 'fake it'. It would involve taking a 'screenshot' (of sorts), splitting it, moving these two images so they meet with an animation, loading the view underneath, and then removing the images. Tricky stuff.

Do you have to have this sort of animation?

If you could post the code you have, I can rearrange it, and add to it, for you.

You'll need to clarify what it is exactly you want to do, though.

UPDATE 3: I added another option for autoreverse.

//You can add both doors into one animation block.

    //Create an animation block. Ease Out is better for this animation but you can change it.
[UIView animateWithDuration:1.0 delay:0.0 options:(UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAutoreverse) animations:^{
    closeDoor1.center = CGPointMake( closeDoor1.center.x +160, closeDoor1.center.y);
    closeDoor2.center = CGPointMake( closeDoor2.center.x -160, closeDoor2.center.y);

}completion:^(BOOL finished){
    if (finished) {
            //When finished, create the VC if it doesn't exist, and insert it below the 'closed door'.

        if (newViewController == nil) {
            UIViewController *newViewController = [[UIViewController alloc] initWithNibName:@"theView" bundle:nil]; 
        }

        [self.view insertSubview:newViewController.view belowSubview: closeDoor2];;
        [self.closeDoor1 removeFromSuperview];
        [self.closeDoor2 removeFromSuperview];

    }
}];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文