小编Ros*_*mes的帖子

获取有关LLDB中内存不良地址的信息

我正在尝试在我的iPhone应用程序中调试EXC_BAD_ACCESS.它正在崩溃一个方法调用,并在方法的行上EXC_BAD_ACCESS (code=1, address = xxx).

以前,我刚刚gdb info malloc-history <xxx>开始调试,但是我找不到并行命令LLDB.

我看到这个线程说要使用Instruments,但是当我这样做时,我仍然会遇到崩溃,但我无法弄清楚如何准确地告诉应用程序在Instruments中崩溃的位置.

我只需要弄清楚崩溃的这块内存指向的位置.使用LLDB或使用仪器的最佳方法是什么?

iphone exc-bad-access lldb

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

将[UICollectionView performBatchUpdates:]与具有UIDynamics的UICollectionViewFlowLayout一起使用

好的基本概述.我有一个UICollectionView我需要支持通过该performBatchUpdates:方法添加和删​​除项目.如果我使用标准UICollectionViewFlowLayout,它工作正常.

但是,当我尝试使用UICollectionViewFlowLayout由a驱动的时UIDynamicAnimator,我一打电话就会崩溃performBatchChanges.

在我的自定义UICollectionViewFlowLayout类中,prepareForCollectionViewUpdates:永远不会调用该方法.UICollectionViewFlowLayout我使用的自定义基于此示例.

崩溃后的控制台输出是......

*** Assertion failure in -[UICollectionViewData layoutAttributesForItemAtIndexPath:], /SourceCache/UIKit/UIKit-2903.23/UICollectionViewData.m:581
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'no UICollectionViewLayoutAttributes instance for -layoutAttributesForItemAtIndexPath: <NSIndexPath: 0xc000000000028096> {length = 2, path = 2 - 5}'
*** First throw call stack:
libc++abi.dylib: terminating with uncaught exception of type NSException
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

objective-c ios uicollectionview uicollectionviewlayout uikit-dynamics

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

如何从CMutablePointer <CGFloat>转到Swift中的CGFloat []

我正在尝试将使用Facebook的pop库的ObjC类转换为Swift.Pop使用相当多的C.

在ObjC中,我有一个看起来像这样的块......

prop.readBlock = ^(SHVGraphViewObjc *graphView, CGFloat values[]) {
                values[0] = [graphView.centerOffsets[idx] doubleValue];
            };
Run Code Online (Sandbox Code Playgroud)

Swift中的等效闭包定义是

prop.readBlock = {(graphView: AnyObject!, values: CMutablePointer<CGFloat>) in }

我无法弄清楚如何将其转换values[0] = [graphView.centerOffsets[idx] doubleValue];为Swift?我怎么让Swift知道CMutablePointer<CGFloat>应该是一个CGFloat[]

swift

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

自定义UIButton Shape而不使用图像

我想制作一个类似于UIBackBarButtonItem的UIButton(向左指向导航堆栈的箭头.我更愿意这样做而不必使用图像,如果可能的话,因为按钮将具有不同的大小,具体取决于手机的取向.

有没有办法在代码中激活这种影响?我的想法是以某种方式使用按钮的CALayer.

谢谢!

编辑

我正在尝试使用@ Deepak的建议,但我遇到了一个问题.我希望按钮的右侧看起来像[UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:4],左侧看起来像箭头.我尝试使用addQuadCurveToPoint:controlPoint方法执行此操作.

我使用矩形的角作为控制点,但路径不像我期望的那样弯曲.它仍然是走投无路的,好像我只使用了addLineToPoint:方法.我的代码如下.

float radius = 4.0;
UIBezierPath *path = [UIBezierPath bezierPath];

CGPoint startPoint = CGPointMake(rect.size.width/5.0, 0);
CGPoint pointBeforeTopCurve = CGPointMake(rect.size.width - radius, 0);
CGPoint topRightCorner = CGPointMake(rect.size.width, 0);
CGPoint pointAfterTopCurve = CGPointMake(rect.size.width, 0.0-radius);

CGPoint pointBeforeBottomCurve = CGPointMake(rect.size.width, rect.size.height-radius);
CGPoint bottomRightCorner = CGPointMake(rect.size.width, rect.size.height);
CGPoint pointAfterBottomCurve = CGPointMake(rect.size.width - radius, rect.size.height);

CGPoint pointBeforeArrow = CGPointMake(rect.size.width/5.0, rect.size.height);
CGPoint arrowPoint = CGPointMake(0, rect.size.height/2.0);


[path moveToPoint:pointBeforeTopCurve];
[path addQuadCurveToPoint:pointAfterTopCurve controlPoint:topRightCorner];

[path addLineToPoint:pointBeforeBottomCurve];
[path addQuadCurveToPoint:pointAfterBottomCurve controlPoint:bottomRightCorner];


[path addLineToPoint:pointBeforeArrow];
[path …
Run Code Online (Sandbox Code Playgroud)

iphone shape uibutton calayer

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

GLKViewControllerDelegate被阻止

我有一个GLKViewController来处理一些OpenGL绘图.我已经实现了glkView:drawInRectupdate方法,并将preferredFramesPerSecond属性设置为30(默认值).

问题是当用户与应用程序的其他部分交互时,委托方法停止触发.我见过这种情况的两种情况是当用户滚动UITableView或与MKMapView交互时.

有没有办法确保这些代表总是触发,无论应用程序的其余部分在做什么.我希望这些停止的唯一时间是应用程序进入后台(这是自动进行).

iphone opengl-es mapkit glkit

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

借鉴自定义MKOverlay

我使用自定义MKOverlay通过MKMapView绘制天气数据.该图纸正在CoreGraphics中完成.对于这种特殊情况,仅仅在drawMapRect:zoomScale:inContext:方法中进行绘制是不够的,因为它处理平铺的方式.我需要立即绘制整个图像,而不是像drawMapRect方法那样平铺.

之前,我在.gif中有雷达图像所以我只是添加了一个imageView并在drawMapRect中调整了imageView框架的大小.

我的计划是做一些类似的事情.添加自定义UIView并在drawMapRect中调用setNeedsDisplay.

这是相关的代码.

MKOverlay对象的boundingMapRect属性:

- (MKMapRect)boundingMapRect
{
    CLLocationCoordinate2D upperLeftCoord = 
    CLLocationCoordinate2DMake(weatherData.radarArray.connectedRadar.latitude + 2.5,
                           weatherData.radarArray.connectedRadar.longitude - 2.5);

    MKMapPoint upperLeft = MKMapPointForCoordinate(upperLeftCoord);

    CLLocationCoordinate2D lowerRightCoord = 
    CLLocationCoordinate2DMake(weatherData.radarArray.connectedRadar.latitude - 2.5,
                           weatherData.radarArray.connectedRadar.longitude + 2.5);

    MKMapPoint lowerRight = MKMapPointForCoordinate(lowerRightCoord);

    double width = lowerRight.x - upperLeft.x;
    double height = lowerRight.y - upperLeft.y;

    MKMapRect bounds = MKMapRectMake(upperLeft.x, upperLeft.y, width, height);

    return bounds;
}
Run Code Online (Sandbox Code Playgroud)

工作drawMapRect:zoomScale:inContext:代码(太慢了).

- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {

    int numPaths = parser.dataPaths.size();

    // We have to pad the map rect a lot to allow for visibility …
Run Code Online (Sandbox Code Playgroud)

iphone overlay core-graphics mapkit

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

使用CGShading显示和颜色数组

我有一个CGColors数组,我需要在路径上显示.我尝试用CGGradient做这个,但我不希望颜色是值之间的混合.看起来最好的解决方案是使用GGShading对象,但我无法弄清楚它们是如何工作的.我主要想知道我需要为CGShading的CGFunction输入做些什么.

有人能指出我正确的方向,我需要使这个CGFunction看起来只是在指定的CGPath上显示一个数组去CGColors吗?

谢谢!

iphone core-graphics

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

类扩展中变量属性的自动合成

我需要添加一个实例变量和两个使用该实例变量的方法到UIViewController.我在类扩展中为变量添加了一个属性.然后我为UIViewController创建了一个具有方法名称的类别.类别头文件导入类扩展.

要使用该类别,我将在我自己的自定义视图控制器中导入它.但是,当我调用其中一个类别方法(使用扩展中声明的属性)时,它会崩溃.

我可以通过在UIViewController的子类中合成属性来解决这个问题,但我认为这些应该自动合成.

我错过了什么吗?

UIViewController_CustomObject.h(扩展标题)

 #import <UIKit/UIKit.h>
 #import "CustomObject.h"

 @interface UIViewController ()

 @property (nonatomic, strong) CustomObject *customObject;

 @end
Run Code Online (Sandbox Code Playgroud)

UIViewController + CustomObject.h(类别标题)

 #import <UIKit/UIKit.h>
 #import "UIViewController_CustomObject.h"

 @interface UIViewController (CustomObject)

 - (void)customMethod;
Run Code Online (Sandbox Code Playgroud)

@结束

UIViewController + CustomObject.m(类别实现)

 #import "UIViewController+CustomObject.h"

 @implementation UIViewController (CustomObject)

 - (void)customMethod
 {
      [self.customObject doSomething];
 }
Run Code Online (Sandbox Code Playgroud)

@结束

iphone xcode objective-c

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

获取iOS共享/操作扩展仅显示单个图像

我在iOS应用程序中有一个操作扩展,我只希望在用户共享单个图像时可用.NSExtension我的关键info.plist看起来像这样.

<key>NSExtension</key>
<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationRule</key>
        <dict>
            <key>NSExtensionActivationSupportsImagesWithMaxCount</key>
            <integer>1</integer>
        </dict>
    </dict>
    <key>NSExtensionMainStoryboard</key>
    <string>MainInterface</string>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.ui-services</string>
</dict>
Run Code Online (Sandbox Code Playgroud)

我使用的唯一激活规则是NSExtensionActivationSupportsImagesWithMaxCount值为1.但是,在分享其他内容时,扩展程序仍会显示.例如,当我点击Safari中的操作按钮时,它会显示出来.

在Safari的情况下,没有图像被拉出NSExtensionContext.

任何人都知道如何让我的扩展程序在这些情况下显示?

ios ios-extensions

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