小编zam*_*ono的帖子

如何在UIScrollView中获取UIView中对象的位置

所以假设我有一个UIScrollView,其中有3个UIViews,其中每个都有一个UISlider.它们垂直放置在UIScrollView中.

我现在在UIScrollView中也有第4个UIView,我想根据已经使用的滑块的位置移动它.

所以在我传递发送者的sliderChanged方法中,我得到了滑块的位置,并将第4个UIWindow的位置调整为y.这在第一个UIView上运行得很好,但是一次在另一个迫使我向下滚动的UIView上,使用滑块移动第四个UIView但是停留在UIScrollView的开头

我在用:

[4thView setCenter:CGPointMake([4thView center].x, [slider center].y+10)];
Run Code Online (Sandbox Code Playgroud)

我需要的是获取滑块的位置相对于scrollView的内容而不是相对于它的UIView,以便我可以相对于scrollView内容再次设置第四个视图.

iphone position uiscrollview uiview uislider

13
推荐指数
2
解决办法
2万
查看次数

如何在iPhone中删除阴影

我正在使用以编程方式从按钮制作阴影的标准方法,但我想在完成按钮后不再存在阴影.我可以将不透明度设置为0,但阴影仍然存在,如果是这样,它仍然会对系统征税.谢谢

这给出了一个错误

tempButton.superview.layer.shadowOffset = nil;
    tempButton.superview.layer.shadowRadius = nil;
    tempButton.superview.layer.shadowOpacity = nil;
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch shadow uiview

8
推荐指数
1
解决办法
5362
查看次数

在使用NSOperationQueue并尝试更改滑块/拾取器等时遇到iphone设备上的大量泄漏

在使用NSOperationQueue并尝试更改滑块/拾取器等时遇到iphone设备上的大量泄漏

我能够毫无问题地更改标签,但如果我尝试更改在界面构建器上创建的滑块或选取器,我会收到这些泄漏.

Leaked Object   #   Address Size    Responsible Library         Responsible Frame
GeneralBlock-16     0x1b00a0    16  GraphicsServices    GetFontNames
GeneralBlock-16     0x1aea90    16  WebCore                WebThreadCurrentContext
GeneralBlock-16     0x1aea80    16  GraphicsServices    GSFontGetFamilyName
GeneralBlock-64     0x1a7370    64  UIKit                  GetContextStack
Run Code Online (Sandbox Code Playgroud)

代码如下

- (void)loadData {

    NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
                                                                            selector:@selector(firstRun)
                                                                              object:nil];

    [queue_ addOperation:operation];
    [operation release];
}

- (void)firstRun {

    NSAutoreleasePool *pool = [NSAutoreleasePool new];

    [self setSliders];

    NSLog(@"firstRun method end");

    [pool drain];

}

- (void)setSliders {  

    NSMutableArray *tempArray = [[[NSMutableArray alloc]init] autorelease];
    aquaplannerAppDelegate *appDelegate = (aquaplannerAppDelegate *)[[UIApplication sharedApplication] delegate]; …
Run Code Online (Sandbox Code Playgroud)

iphone memory-leaks instruments nsoperationqueue nsautoreleasepool

5
推荐指数
1
解决办法
1447
查看次数

调用者此时不拥有的对象的引用计数的不正确的减少

iPhone上的调用者不在此时拥有的对象的引用计数的不正确的减少.它发生在NSString,我明确地在for循环中初始化和释放.我试图像autoreleases字符串一样做,但我得到了泄漏.我认为罪魁祸首是stringbytrimming调用.任何建议,顺便说一下这不泄漏,但我在构建和分析中得到警告.一切也很好,应用程序不会崩溃.

for(int i=0;i<storyQuantity;i++) {
            NSString *imageString = [[NSString alloc] init];
            imageString = [[[storiesArray objectAtIndex:i] objectForKey: @"image"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];  // must add trimming to remove characters

            imageLoader *imageOperation = [[imageLoader alloc] initWithImageURL:imageString target:self action:@selector(didImageLoad:) number:i];

            AppDelegate_iPad *appDelegate = [[UIApplication sharedApplication] delegate];
            [appDelegate.queue_ addOperation:imageOperation];
            [imageOperation release];
            [imageString release];
        }
Run Code Online (Sandbox Code Playgroud)

UPDATE - 添加了我的imageLoader类,据我所知,这个类没有泄漏

- (id)initWithImageURL:(NSString *)url target:(id)target action:(SEL)action number:(int)number {
    if(self = [super init]) {
        _action = action;
        _target = target;
        _number = number;
        if(url == nil) {
            return nil;
        } else { …
Run Code Online (Sandbox Code Playgroud)

memory iphone xcode trim nsstring

3
推荐指数
1
解决办法
3251
查看次数