小编inc*_*iko的帖子

iOS 7.1 removeFromSuperview崩溃

iOS 7.1发布之前,我的应用程序没有任何崩溃.现在任何removeFromSuperview方法,崩溃.例如:我有视图控制器,当我想删除一个视图控制器时,我删除它的所有子视图,然后从堆栈中删除(堆栈:我在此存储视图控制器,用于加载新内容,并加载以前的内容):

    for (UIView *subView in [contentVc subviews])
         [subView removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)

我得到了

- [CALayer retain]:发送到解除分配实例的消息

信息

[actual removeFromParentViewController];
Run Code Online (Sandbox Code Playgroud)

是一个删除它的好方法?它会释放整个视图控制器及其子视图吗?因为而不是removeFromSuperview,我的应用程序不会崩溃.我不明白iOS 7.1中有什么变化.

我怎样才能删除所有子视图中viewController没有removeFromSuperview,没有删除我的ViewController(如果我只是想添加新的子视图,并删除当前内容)?

更新:

有时崩溃:

[myactualviewcontroller.view removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)

- [CALayer retain]:发送到解除分配实例的消息

为什么???

有时如果我尝试从视图控制器视图中删除主子视图,它会发生同样的崩溃:

[mainView removeFromSuperview] (mainView是单个UIView,添加到vc.view)

更新2 :(详细)

所以,我有一个容器视图.我正在UIViewController.view为这个容器添加一个.我正在添加一个视图作为子视图UIViewController.view.这个视图不是本地uiview,我的意思是,它声明为implementation{ UIView* mainView }.当我的UIViewController将被解除分配时,在它- (void) dealloc { [mainView removeFromSuperview]; [mainView release] [super dealloc];} 的主视图removeFromSuperview我的应用程序崩溃.

objective-c subview ios ios7.1

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

使用AVCaptureSession sessionPreset = AVCaptureSessionPresetPhoto拉伸捕获的照片

重要提示:如果我使用: session.sessionPreset = AVCaptureSessionPresetHigh;我的预览图像没有拉伸!! 如果我将照片保存到设备中,UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);则图像正常,只有在预览中才会拉伸.

我正在使用AVFoundation捕捉照片.

session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetHigh;

CALayer *viewLayer = vImagePreview.layer;
NSLog(@"viewLayer = %@", viewLayer);

AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];

captureVideoPreviewLayer.frame = vImagePreview.bounds;
[vImagePreview.layer addSublayer:captureVideoPreviewLayer];

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
if (!input) {
    // Handle the error appropriately.
    NSLog(@"ERROR: trying to open camera: %@", error);
}
[session addInput:input];

stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
NSDictionary *outputSettings = …
Run Code Online (Sandbox Code Playgroud)

avfoundation ios avcapturesession

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

iTunes Store作为模态视图

我想在我的应用程序中打开一些iTunes歌曲的链接,但我不想从我的应用程序重定向到应用程序商店.我想打开iTunes Store作为Facebook的模态视图,当您按下赞助应用程序时这样做.我该怎么做?(在"自制"模式视图与Web视图??我希望不是)

例如,如何打开此链接作为模态视图,用户可以在那里购买: @"https://itunes.apple.com/us/album/how-i-feel/id731197191?i=731197197&ign-mpt=uo%3D4"

现在我正在使用这个:

[[UIApplication sharedApplication]
 openURL:[NSURL URLWithString:@"itms://itunes.apple.com/us/album/how-i-feel/id731197191?i=731197197&uo=4"]];
Run Code Online (Sandbox Code Playgroud)

当然它不会以模态视图打开.

objective-c itunes-store modalviewcontroller ios

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

com.apple.developer.healthkit.access警告

我已经添加并创建了分配给HealthKit的所有内容,但xcode显示此警告:

代码签名警告:“ ..”的供应配置文件“ ..”包含的权利不在权利文件:com.apple.developer.healthkit.access中。要使用这些权利,请将它们添加到您的权利文件中。否则,请从您的配置文件中删除未使用的权利。

我试图将com.apple.developer.healthkit.access键添加为布尔值,但是xcode无法解析该授权键值(生成构建错误)。带有healthkit的应用程序中的所有内容均正常运行,但我也担心最终发行版和开发版发行版。

更新资料

因为我不明白这是什么警告,也不想在权利中添加不必要的行,所以我将新版本的应用程序上载到了App Store。 苹果并没有收到任何拒绝的消息,所以现在可以出售了。对于那些担心拒绝的人来说,这可能是有用的信息。

xcode warnings ios healthkit

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

touchesEnd没有被称为bit touchesBegin和touchesMoved被调用

我试图在ios中拖延.如果拖动移动距离很短,我会将拖动计为点击事件,方法是将开始x,y(来自touchesBegan)与touchesEnd中的x,y进行比较.似乎touchesEnd永远不会被调用.我给了一个断点来验证它并且断点从未消失.

code:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    NSUInteger touchCount = [touches count];
    NSUInteger tapCount = [[touches anyObject] tapCount];

    [ self UpdateDrag];

   }

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    NSUInteger touchCount = [touches count];
    NSUInteger tapCount = [[touches anyObject] tapCount];

    }


- (void) touchesEnd:(NSSet *)touches withEvent:(UIEvent *)event {
   // this methes never gets called 
    NSUInteger touchCount = [touches count];
    NSUInteger tapCount = [[touches anyObject] tapCount];


    if (mDisplay==nil)
    {
        mDisplay = [[cDisplayYesOrNo_iPhone alloc]
                    initWithNibName:@"cDisplayYesOrNo_iPhone"
                    bundle:[NSBundle mainBundle]];
    }
    [ mDisplay …
Run Code Online (Sandbox Code Playgroud)

ios

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

Firebase崩溃批量上传因未知原因而失败

我正在尝试将DSYM上传到firebase,直到几天才完美运行.当我启动脚本时,它开始登录,在它停留几分钟然后失败后几行.

/Users/..../dSYMs/DF...C47.dSYM/Contents/Resources/DWARF/leveldb: warning: function at offset 0x51662 has no name
./Pods/FirebaseCrash/upload-sym-util.bash:365: error: upload: Unable to upload symbol file (reason unknown).
Run Code Online (Sandbox Code Playgroud)

有趣的是,在firebase控制台中它告诉我上传成功:

UUID B4 ... AAF的未来堆栈跟踪将使用上载的符号文件进行符号化.

但它永远不会,因为我已经"上传"了一些像这样的东西,从那以后,我又发生了一些崩溃,但仍然没有象征意义......

这是怎么回事?

仅供参考:我从二月开始使用firebase crashreporting,它运行良好.我几天前将我的mac更新到High Sierra.

你的

ios firebase firebase-crash-reporting

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

带有“(”“)”括号的JSON,而不是“ [”“]”

在.m中:

   @implementation ViewController
    {
    NSDictionary *_json;
}

- (void)viewDidLoad
{
    [super viewDidLoad];


    NSURL* url = [NSURL URLWithString:@"http://api.worldweatheronline.com/free/v1/weather.ashx?q=Si%C3%B3fok&format=json&num_of_days=5&key=mykey"];

    NSData *jsonData = [NSData dataWithContentsOfURL:url];

    NSError *error;
    _json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];

    NSDictionary* fullDictFromjson = _json[@"data"];

    NSLog(@"%@",fullDictFromjson);

    NSDictionary* currentCondition = fullDictFromjson[@"current_condition"];

    NSLog(@"%@",currentCondition);
Run Code Online (Sandbox Code Playgroud)

之后,我在Console(currentCondition)中得到了这个:

2013-04-18 22:18:16.758 weather[18111:c07] (
        {
        cloudcover = 0;
        humidity = 74;
        "observation_time" = "08:18 PM";
        precipMM = "0.0";
        pressure = 1019;
        "temp_C" = 11;
        "temp_F" = 51;
        visibility = 10;
        weatherCode = 113;
        weatherDesc =         (
                        {
                value = …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch json ios

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