首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >奇怪的滚动问题( UIScrollView )

奇怪的滚动问题( UIScrollView )
EN

Stack Overflow用户
提问于 2011-02-21 23:07:00
回答 1查看 405关注 0票数 0

我已经在这上面找了无数次也没有结果,希望有人能帮上忙!

我在UIView的左半部分有一个加载自定义单元格/子视图的UIScrollView。UIView是UINavigation堆栈的一部分,也被加载到TabBar上的选项卡中。

发生的情况是,如果我启动应用程序并立即开始滚动,它会非常流畅。然而,如果我启动应用程序并等待5-10秒,UIScrollView就会变得非常迟缓和不稳定(并且一直如此)。我会认为这可能是内存泄漏或其他什么,但我似乎找不到任何东西。

其中包含了将自定义单元格/子视图加载到UIScrollView中的视图的代码。单元格子视图中没有任何自定义代码。哦,而且只有8-10个项目:每个项目都有一个小的(150x150)图像和3个文本字段-都是不透明的。

代码语言:javascript
复制
    #import "ProductListViewController.h"
    #import "ProductListLeftItemViewController.h"


    @implementation ProductListViewController

    @synthesize listScroll;



    - (void)viewDidLoad {

        NSBundle *bundle = [NSBundle mainBundle];
        NSString *path = [bundle pathForResource:@"Products" ofType:@"plist"];
        NSArray *products = [[NSArray alloc] initWithContentsOfFile:path];
        //  
        int numProducts;
        numProducts = [products count];
        [listScroll setContentSize:CGSizeMake(500, (numProducts * 111))];
        for (int i = 0; i < numProducts; i++) {
            ProductListLeftItemViewController *cellItem = [[ProductListLeftItemViewController alloc] initWithNibName:@"ProductListLeftItem" bundle:nil];
            cellItem.view.frame = CGRectMake(0, (i*111), 500, 111);

            [self.listScroll addSubview:cellItem.view];
            cellItem = nil;
            [cellItem release];
        }
        [products release]; 

        [super viewDidLoad];

    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }

    - (void)didReceiveMemoryWarning {
        // Releases the view if it doesn't have a superview.
        NSLog(@"Memory warning, ProductListViewController");

        [super didReceiveMemoryWarning];

        // Release any cached data, images, etc that aren't in use.
    }

    - (void)viewDidUnload {
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }


    - (void)dealloc {
        [listScroll release];
        [super dealloc];
    }

    @end

按照要求,ProductListLeftItemViewController代码如下:

代码语言:javascript
复制
#import "ProductListLeftItemViewController.h"


@implementation ProductListLeftItemViewController

@synthesize titleTxt, descriptionTxt, modelTxt, productThumb;


 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


- (void)viewDidUnload {
    titleTxt = nil;
    descriptionTxt = nil;
    modelTxt = nil;
    productThumb = nil;


    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [titleTxt release];
    [descriptionTxt release];
    [modelTxt release];
    [productThumb release];
    [super dealloc];
}


@end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-18 04:22:34

对于将来遇到这个问题的任何人来说,一旦我开始在实际设备上测试,一切都非常顺利。也许这只是模拟器的怪异之处?我会认为这个问题已经解决了,尽管我还会进一步研究它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5067559

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档