English 中文(简体)
不同观点――推论
原标题:Navigating to a different view - pushViewController

我有一张表格,在一行点击时,我去了另一种观点;导航部分的代码如下所示;

ShowImageController *showImageController = [[HowItWorksViewController alloc] initWithNibName:nil bundle:nil];

[self.navigationController pushViewController:showImageController  animated:YES];

另一种观点含有一种形象,即把形象添加到其观点中。 并在此附上该守则

 UIImageView *imageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hello.png"]];
    [imageView setFrame:CGRectMake(o, o, 200, 300)];

[[self view] addSubview:imageView ];

问题在于,在一行点击时,需要很长的时间(极慢),才能去其他屏幕。

注:Ros在另一种观点中的形象没有问题。 为什么发生这种情况? 如何确定?

问题回答

a. 将图像装入一个星号或星号:

象图像这样的明显声音是大的,因此在装上。 我建议你要么使用较小的图像,要么如果你不控制这些图像,那么你可能会试图在背景中填满图像。 下面是一些守则,使你开始装上底线:

- (void)decodeImageInBackgroundThread:(UIImage*)decodedImage forImageView:(UIImageView*)imageView {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
        CGImageRef originalImage = [decodedImage CGImage];

        CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(originalImage));
        CGDataProviderRef imageDataProvider = CGDataProviderCreateWithCFData(imageData);

        if (imageData != NULL) {
            CFRelease(imageData);
        }

        CGImageRef image = CGImageCreate(CGImageGetWidth(originalImage),
                                         CGImageGetHeight(originalImage),
                                         CGImageGetBitsPerComponent(originalImage),
                                         CGImageGetBitsPerPixel(originalImage),
                                         CGImageGetBytesPerRow(originalImage),
                                         CGImageGetColorSpace(originalImage),
                                         CGImageGetBitmapInfo(originalImage),
                                         imageDataProvider,
                                         CGImageGetDecode(originalImage),
                                         CGImageGetShouldInterpolate(originalImage),
                                         CGImageGetRenderingIntent(originalImage));

        if (imageDataProvider != NULL) {
            CGDataProviderRelease(imageDataProvider);
        }

        dispatch_async(dispatch_get_main_queue(), ^{
            [imageView setImage:[UIImage imageWithCGImage:image]];
            CGImageRelease(image);
        });
    });
}

你们可以这样作:

- (void)viewDidLoad {
    ...

    UIImage *image = [UIImage imageNamed:@"hello.png"];

    UIImageView *imageView = [[UIImageView alloc] initWithImage:nil];
    [imageView setFrame:CGRectMake(0.0f, 0.0f, 200.0f, 300.0f)];
    [[self view] addSubview:imageView];

    [self decodeImageInBackgroundThread:image forImageView:imageView];
}




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签