ipad – iOS8beta中的UIActionSheet崩溃

ipad – iOS8beta中的UIActionSheet崩溃,第1张

概述我有一些代码,只需点击按钮即可显示UIActionSheet. 但是当我在iPad中使用XCode5.1 iOS8beta构建它时会崩溃. 下面是我用来显示UIActionSheet的代码. UIActionSheet *tmpActionSheet = [[UIActionSheet alloc] initWithTitle:nil 我有一些代码,只需点击按钮即可显示UIActionSheet.
但是当我在iPad中使用XCode5.1 iOS8beta构建它时会崩溃.

下面是我用来显示UIActionSheet的代码.

UIActionSheet *tmpActionSheet = [[UIActionSheet alloc] initWithTitle:nil                                                                delegate:self                                                       cancelbuttonTitle:@"Cancel"                                                  destructivebuttonTitle:nil                                                       otherbuttonTitles:                                     @"Ok",nil];    [tmpActionSheet showInVIEw:self.vIEw];

注意:
– 完美适用于XCode6beta iOS8beta(iPhone / iPad)
– 完美适用于XCode5.1 iOS8beta(仅限iPhone)

异常的日志记录如下.

2014-06-23 15:54:04.860 ActionSheetDemo[680:191598] Unable to simultaneously satisfy constraints.    Probably at least one of the constraints in the following List is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSautoresizingMaskLayoutConstraints that you don't understand,refer to the documentation for the UIVIEw property translatesautoresizingMaskIntoConstraints) (    "<NSLayoutConstraint:0x14e60ef0 V:|-(0)-[UIVIEw:0x14d419a0]   (names: '|':UIVIEw:0x14d3a8b0 )>","<NSLayoutConstraint:0x14e60880 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.top == UIVIEw:0x14d419a0.top>","<NSLayoutConstraint:0x14e61600 V:[_UIDimmingKnockoutBackdropVIEw:0x14d2ca80(>=44)]>","<NSLayoutConstraint:0x14e66240 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.bottom ==>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x14e66240 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.bottom ==>Make a symbolic breakpoint at UIVIEwAlertForUnsatisfiableConstraints to catch this in the deBUGger.The methods in the UIConstraintBasedLayoutDeBUGging category on UIVIEw Listed in <UIKit/UIVIEw.h> may also be helpful.2014-06-23 15:54:04.872 ActionSheetDemo[680:191598] Unable to simultaneously satisfy constraints.    Probably at least one of the constraints in the following List is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSautoresizingMaskLayoutConstraints that you don't understand,"<NSLayoutConstraint:0x14d25f80 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.bottom ==>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x14d25f80 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.bottom ==>Make a symbolic breakpoint at UIVIEwAlertForUnsatisfiableConstraints to catch this in the deBUGger.The methods in the UIConstraintBasedLayoutDeBUGging category on UIVIEw Listed in <UIKit/UIVIEw.h> may also be helpful.2014-06-23 15:54:04.878 ActionSheetDemo[680:191598] Unable to simultaneously satisfy constraints.    Probably at least one of the constraints in the following List is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSautoresizingMaskLayoutConstraints that you don't understand,"<NSLayoutConstraint:0x14e67740 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.bottom ==>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x14e67740 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.bottom ==>Make a symbolic breakpoint at UIVIEwAlertForUnsatisfiableConstraints to catch this in the deBUGger.The methods in the UIConstraintBasedLayoutDeBUGging category on UIVIEw Listed in <UIKit/UIVIEw.h> may also be helpful.2014-06-23 15:54:04.885 ActionSheetDemo[680:191598] Unable to simultaneously satisfy constraints.    Probably at least one of the constraints in the following List is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSautoresizingMaskLayoutConstraints that you don't understand,"<NSLayoutConstraint:0x14d38a30 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.bottom ==>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x14d38a30 _UIDimmingKnockoutBackdropVIEw:0x14d2ca80.bottom ==>Make a symbolic breakpoint at UIVIEwAlertForUnsatisfiableConstraints to catch this in the deBUGger.The methods in the UIConstraintBasedLayoutDeBUGging category on UIVIEw Listed in <UIKit/UIVIEw.h> may also be helpful.2014-06-23 15:54:04.892 ActionSheetDemo[680:191598] *** Terminating app due to uncaught exception 'NSinvalidargumentexception',reason: 'Application trIEd to present modally an active controller <_UIAlertShimPresentingVIEwController: 0x14d450c0>.'*** First throw call stack:(0x24702c2f 0x315cdd1f 0x27ffa6e7 0x27df9799 0x2838f3bd 0x2838e94d 0x6bfdd 0x27d4a6c7 0x27d4a669 0x27d34a4d 0x27d4a099 0x27d49d73 0x27d42ff1 0x27d198b1 0x27f8f13d 0x27d183c1 0x246ca597 0x246c99ab 0x246c8029 0x246145a1 0x246143b3 0x2b8cc1b9 0x27d78c41 0x6c239 0x31b67aaf)libc++abi.dylib: terminating with uncaught exception of type NSException

题 :
1]为什么我的应用程序崩溃?
2]是iOS8beta的BUG吗?

补丁直到苹果解决了这个问题
为UIActionSheet类创建Objective-C分类

代码:

#define SYstem_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)#define SYstem_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)#define SYstem_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)#define SYstem_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)#define SYstem_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)@implementation UIActionSheet (simplyShowInVIEwAddition)- (voID) simplyShowInVIEw:(UIVIEw *) vIEw{    if(SYstem_VERSION_LESS_THAN(@"8.0"))    {        [self showInVIEw:vIEw];    }    else    {        // "Translating" UIActionSheet to UIAlertController for better compatibility with iOS 8        UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:self.Title preferredStyle:UIAlertControllerStyleActionSheet];        int nactions = [self numberOfbuttons];        int i=0;        while(i<nactions)        {            Nsstring *button_Title=[self buttonTitleAtIndex:i];            UIAlertActionStyle style=UIAlertActionStyleDefault;            if(i==[self cancelbuttonIndex])            {                style = UIAlertActionStyleCancel;            }            else if(i==[self destructivebuttonIndex])            {                style = UIAlertActionStyleDestructive;            }            UIAlertAction *newAction = [UIAlertAction actionWithTitle:button_Title style:style handler:^(UIAlertAction *action) {                NSLog(@"clicked action %d",i);                [self.delegate actionSheet:self clickedbuttonAtIndex:i];            }];            [alert addAction:newAction];            i++;        }        if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad)        {            [alert setModalPresentationStyle:UIModalPresentationPopover];            UIPopoverPresentationController *popPresenter = [alert                                                             popoverPresentationController];            popPresenter.sourceVIEw = vIEw;            popPresenter.sourceRect = CGRectMake(vIEw.frame.size.wIDth/2-1,0.45*vIEw.frame.size.height,2,1);            popPresenter.permittedArrowDirections = 0;        }        UIVIEwController *sourceVIEwController;        if(self.delegate!=nil && [self.delegate respondsToSelector:@selector(presentVIEwController:animated:completion:)])        {            NSLog(@"presenting UIAlertController on source vIEw controller");            sourceVIEwController=(UIVIEwController *)(self.delegate);        }        else        {            // When the actionsheet delegate is not a UIVIEwController            NSLog(@"presenting UIAlertController on displayed vIEw controller");            sourceVIEwController = /* Set up a method here to obtain the vIEw controller where you want to display it */        }        [sourceVIEwController presentVIEwController:alert animated:YES completion:nil];    }}

参考link

解决方法 我也有同样的问题.我使用ShowFrombarbuttonItem函数而不是ShowInVIEw函数.

[organizeActionSheet showFrombarbuttonItem:btnAction animated:NO];

如果使用ShowFromrect或showFrombarbuttonItem运行时异常将不会到来.
我认为这是IOS8 Beta的一个错误,当我使用ShowInVIEw运行时异常即将到来.

这个错误在IOS Beta 4中没有发生..

当使用Xcode 5.1构建时,我在调试窗口中收到一些警告消息,但确实出现了 *** 作表.在iOS 8 beta 4中,它显示为视图外侧的小d出窗口(侧面),而在iOS 7中,它曾经显示为从视图底部向上滑动的按钮.

总结

以上是内存溢出为你收集整理的ipad – iOS8beta中的UIActionSheet崩溃全部内容,希望文章能够帮你解决ipad – iOS8beta中的UIActionSheet崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1080407.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存