gpt4 book ai didi

ios - 'UIView' 可能无法响应 'addSubview:withAnimation:'

转载 作者:行者123 更新时间:2023-12-01 18:00:07 30 4
gpt4 key购买 nike

我收到了这个警告:

'UIView' may not respond to 'addSubview:withAnimation:'

产生该警告的代码行是这样的:
[self.masterView addSubview:self.detailImage withAnimation:def];

而我的相关代码是这样的:
ExUIViewAnimationDefinition *def = [[ExUIViewAnimationDefinition alloc] init];
def.type = ExUIAnimationTypeTransition;
def.direction = ExUIAnimationDirectionMoveUp;
[self.masterView addSubview:self.detailImage withAnimation:def];
[def release];

我看了 UIView文档,我认为 addSubview 可能已被弃用,但它仍然是这样的。

有谁知道如何解决这个警告?提前谢谢。

最佳答案

addSubview是 UIView 将响应的方法。 addSubview:withAnimation:不是 UIView 将响应的方法。

如果你想添加一个带有淡入淡出或类似的 subview ,试试这个:

self.detailImage.alpha = 0.0;
[self.masterView addSubview:self.detailImage];

[UIView animateWithDuration:0.3 animations:^{
self.detailImage.alpha = 1.0;
}];

关于ios - 'UIView' 可能无法响应 'addSubview:withAnimation:',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11077996/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com