开发者

iOS 3.X SIGABRT setting modalPresentationStyle, works fine on 4.2 iPod Touch

Settings the presentation style on an iPod Touch 2G (3.1.3) crashes with SIGBART but works fine on an iPod Touch 4G (4.2). Is this a bug? Can someone give me a workaround?

DateDialogController* dlg = [[DateDialogController alloc] initWithNibName:@"DateDialogView" bundle:nil];
[dlg setDelegate:self];
dlg.startDate = self.anchorDate;
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self.navigationController presentModalViewController:dlg animated:YES];
[dlg release];


2011-08-02 13:44开发者_运维百科:20.785 Mobile Manager[274:207] *** -[UINavigationController setModalPresentationStyle:]: unrecognized selector sent to instance 0x230000
2011-08-02 13:44:20.789 Mobile Manager[274:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UINavigationController setModalPresentationStyle:]: unrecognized selector sent to instance 0x230000'
2011-08-02 13:44:20.799 Mobile Manager[274:207] Stack: (
    864992541,
    859229716,
    864996349,
    864492313,
    864454720,
    346779,
    864749711,
    839231364,
    839231212,
    839231156,
    839230220,
    839233420,
    839227648,
    839225236,
    839206800,
    839205012,
    875886564,
    864740651,
    864738335,
    875880904,
    838872112,
    838865456,
    54257,
    54172
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.


The property you are setting modalPresentationStyle is only available on iOS3.2+ Since your iPod is running 3.1.2 it can't respond to methods that set the property

It's in the UIViewController docs

As for working around it, code like this usually helps.

 DateDialogController* dlg = [[DateDialogController alloc] initWithNibName:@"DateDialogView" bundle:nil];
[dlg setDelegate:self];
dlg.startDate = self.anchorDate;

// Set the property if the iOS version allows it
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];    
if ([currSysVer compare:@"3.2" options:NSNumericSearch] != NSOrderedAscending) {
    self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
}

[self.navigationController presentModalViewController:dlg animated:YES];
[dlg release];
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];    
if ([currSysVer compare:@"3.2" options:NSNumericSearch] != NSOrderedAscending) {
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜