Cocoa touch 为什么我的观点行动迟缓?

Cocoa touch 为什么我的观点行动迟缓?,cocoa-touch,uiview,uiwebview,calayer,Cocoa Touch,Uiview,Uiwebview,Calayer,我有一个UIView控制器,它有一个背景图像和一个UIWebView,设置为通过autoresizeResizingMask属性在方向改变时自动调整大小。它在模拟器中运行平稳,但在设备上预览时非常缓慢 我很少使用web视图CALayer来创建边框和阴影,当我对这些部分进行注释时,它运行得更加平滑。在使用视图CALALER(我怀疑)或是我不正确地执行这些部分时,这是不是很好? 下面是视图加载方法 // Implement viewDidLoad to do additional setup aft

我有一个UIView控制器,它有一个背景图像和一个UIWebView,设置为通过
autoresizeResizingMask
属性在方向改变时自动调整大小。它在模拟器中运行平稳,但在设备上预览时非常缓慢

我很少使用web视图
CALayer
来创建边框和阴影,当我对这些部分进行注释时,它运行得更加平滑。在使用视图CALALER(我怀疑)或是我不正确地执行这些部分时,这是不是很好? 下面是视图加载方法

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {

    NSLog(@"Web project View Controller");
    [super viewDidLoad];

    UIImageView *bg = [[UIImageView alloc] initWithFrame:self.view.bounds];
    bg.contentMode = UIViewContentModeCenter;
    bg.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    bg.image = [UIImage imageNamed:@"fuzzyhalo.png"];
    [self.view addSubview:bg];


    projectView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    projectView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    projectView.layer.backgroundColor = [UIColor blackColor].CGColor;

    projectView.layer.shadowColor = [UIColor blackColor].CGColor;
    projectView.layer.shadowOpacity = 1.0;
    projectView.layer.shadowRadius = 5.0;
    projectView.layer.shadowOffset = CGSizeMake(0, 0);  

    projectView.layer.borderColor = [UIColor blueColor].CGColor;
    projectView.layer.borderWidth = 2.0;


    CGRect newFrame = self.view.bounds;

    newFrame.origin.x = 40;
    newFrame.origin.y = 40;
    newFrame.size.width = newFrame.size.width - 80;
    newFrame.size.height = newFrame.size.height - 80;

    projectView.frame = newFrame;

    [self.view addSubview:projectView];
}
背景图像也相当大。1024x10272ppi巴布亚新几内亚

非常感谢您的帮助。谢谢。

绘制阴影非常昂贵。在iOS 3.2及更高版本中,
CALayer
上有一个名为
shadowPath
的特殊属性。它是一个预先计算的路径,用于定义阴影的轮廓。这使层不必使用层的合成alpha通道动态生成路径。添加这一行应该会有很大帮助:

projectView.layer.shadowPath = 
  [[UIBezierPath bezierPathWithRect:projectView.layer.bounds] CGPath];
阴影画起来很昂贵。在iOS 3.2及更高版本中,
CALayer
上有一个名为
shadowPath
的特殊属性。它是一个预先计算的路径,用于定义阴影的轮廓。这使层不必使用层的合成alpha通道动态生成路径。添加这一行应该会有很大帮助:

projectView.layer.shadowPath = 
  [[UIBezierPath bezierPathWithRect:projectView.layer.bounds] CGPath];