小编roc*_*lin的帖子

SDWebImage和设置自定义HTTP标头?

我刚刚将用于缓存图像的代码从EGOImageCache更改为SDWebView.不幸的是我不知道如何设置自定义HTTP标头,因为我必须发送身份验证才能获取图像.使用EGOImageCache很容易,因为我已经在适当的地方扩展了NSURLRequest.但是我不知道如何使用SDWebView.framework来做到这一点.我看到标题,我在SDWebImageDownloader.h中找到了包含的方法

    /**
 * Set a value for a HTTP header to be appended to each download HTTP request.
 *
 * @param value The value for the header field. Use `nil` value to remove the header.
 * @param field The name of the header field to set.
 */
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;

/**
 * Returns the value of the specified HTTP header field.
 *
 * @return The value associated with the header field field, or `nil` if there is no …
Run Code Online (Sandbox Code Playgroud)

uiimageview image-caching http-headers sdwebimage

20
推荐指数
1
解决办法
9389
查看次数

从未调用过MKAnnotationView viewForAnnotation

在我花了2天的时间搜索这个bug后,我必须在这里寻求帮助.我有MapViewController并在地图上放置一些引脚.我已经从AppleCallouts和WeatherMap复制了苹果代码示例中的大部分代码.

无论如何,我似乎删除或遗漏了必要的部分.似乎MapViewController和以下代码之间没有任何关联

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    NSLog(@"MKAnnotationView");
    return nil;
}
Run Code Online (Sandbox Code Playgroud)

设置注释看起来像这样,它运作良好:

- (void)createPoi:(CLLocationCoordinate2D)theCoordinate
{
    NSLog(@"createPoi");

    RandomAnnotation *randomAnnotation = [[RandomAnnotation alloc] init];
    [randomAnnotation setTheCoordinate:theCoordinate];
    [randomAnnotation setTheTitle:@"bla"];
    [randomAnnotation setTheSubTitle:@"bla"];
    [self.mapAnnotations insertObject:randomAnnotation atIndex:kRandomAnnotationIndex];
    [randomAnnotation release];
    [self.mapView addAnnotation:[self.mapAnnotations objectAtIndex:kRandomAnnotationIndex]];
}
Run Code Online (Sandbox Code Playgroud)

我不知道出了什么问题.任何人都可以给我一些提示吗?我不得不承认我对委托模式没有任何经验.

iphone xcode delegates mkmapview ios

7
推荐指数
1
解决办法
6540
查看次数

UIScrollView的contentOffset

我怎样才能获得contentOffset的x位置?

这是我的代码,但在日志中总是抛出0

- (void)adjustAreaScroll:(NSNotification *)notification
{
    int value = [[notification object] intValue];
    NSLog(@"adjustAreaScroll, %i", value);

    switch (value) {
        case 0:
            [topScroll setContentOffset:CGPointMake(0, 0)];
            break;
        case 1:
            [topScroll setContentOffset:CGPointMake(1024, 0)];
            break;
        case 2:
            [topScroll setContentOffset:CGPointMake(2048, 0)];
            break;
        case 3:
            [topScroll setContentOffset:CGPointMake(3072, 0)];
            break;
    }
    NSLog(@"target position -----> %i", self.topScroll.contentOffset.x);
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiscrollview ipad ios

2
推荐指数
1
解决办法
7605
查看次数

访问数组中的UIView对象

我已经定义了一个数组,其中包含已定义的4个UIView对象

NSArray *districtArray = [NSArray arrayWithObjects:view1, view2, view3, view4, nil];
Run Code Online (Sandbox Code Playgroud)

现在我想为通过索引访问数组的UIView添加一个子视图.我不知道我该怎么写

它应该是那样的

[districtArray[0] addSubview:poiObject];
Run Code Online (Sandbox Code Playgroud)

任何人都可以给我一个关于语法的提示吗?

谢谢!

iphone objective-c uiview addsubview ios

2
推荐指数
1
解决办法
3043
查看次数

夹点识别后夹点结束还是修补?

我只是在寻找一个可以捕获的适当事件.捏效果很好.并且以下行仅在之前没有捏时才起作用

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent*)event 
{
    NSLog(@"---> event");
}
Run Code Online (Sandbox Code Playgroud)

似乎捏捏掉了以下的触摸.

无论如何在这段代码中都能识别出修饰

- (void)scalePiece:(UIPinchGestureRecognizer *)gestureRecognizer
{
    //[self adjustAnchorPointForGestureRecognizer:gestureRecognizer];

    NSLog(@"scalePiece");

    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {
        [gestureRecognizer view].transform = CGAffineTransformScale([[gestureRecognizer view] transform], [gestureRecognizer scale], [gestureRecognizer scale]);
        [gestureRecognizer setScale:1];
    }
}
Run Code Online (Sandbox Code Playgroud)

如何在捏视图后识别最后/第二根手指的触摸?或者更好地说,我如何区分夹点移动和夹点结束?

干杯

iphone objective-c ipad uigesturerecognizer ios

2
推荐指数
1
解决办法
1906
查看次数

在哪里设置背景颜色?

我只是浏览课程一个小时,无法找到它!我开始搜索AAPLot项目的示例.

我稍微更改了图表,并期望在CPTTradingRangePlot类中找到所有设置,但它不存在.

有很多属性我可以改变,但我找不到任何类的背景设置.

任何人都可以给我一个暗示吗?

// OHLC plot
CPTMutableLineStyle *whiteLineStyle = [CPTMutableLineStyle lineStyle];
whiteLineStyle.lineColor = [CPTColor whiteColor];
whiteLineStyle.lineWidth = 1.0f;
CPTTradingRangePlot *ohlcPlot = [[[CPTTradingRangePlot alloc] initWithFrame:graph.bounds] autorelease];
ohlcPlot.identifier = @"OHLC";
ohlcPlot.lineStyle = whiteLineStyle;
ohlcPlot.barWidth = 4.0f;
ohlcPlot.increaseFill = [(CPTFill *)[CPTFill alloc] initWithColor:[CPTColor greenColor]];
ohlcPlot.decreaseFill = [(CPTFill *)[CPTFill alloc] initWithColor:[CPTColor redColor]];
    CPTMutableTextStyle *whiteTextStyle = [CPTMutableTextStyle textStyle];
whiteTextStyle.color = [CPTColor whiteColor];
    whiteTextStyle.fontSize = 12.0;
    ohlcPlot.labelTextStyle = whiteTextStyle;
    ohlcPlot.labelOffset = 5.0;
ohlcPlot.stickLength = 2.0f;
ohlcPlot.dataSource = self;
ohlcPlot.plotStyle = CPTTradingRangePlotStyleCandleStick;
[graph addPlot:ohlcPlot];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c core-plot candlestick-chart ios

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