The following code works as expected on iOS4.3 iPhone and iPad, and iOS5 iPhone, but crashes on iOS5 iPad. This is called for the first view that I call in a Tab based application, when the prior run of the application was cancelled. The user can continue the prior run or reset. I have tried moving this code to both the -viewWillAppear and -viewDidAppear secant, to no avail. Has anyone else experienced this? (Btw, I have confirmed all the connections in my XIBs to make sure it wasn't a problem with iPad parts of this UniversalApp.
- (void)viewDidLoad {
BOOL continueYesNo;
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
continueYesNo = [prefs boolForKey:@"keyContinueMeeting"];
if (continueYesNo) {
NSString *message_continue = [[NSString alloc] initWithFormat:@"Do you want to Continue the Prior event"];
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:message_continue
delegate:self
cancelButtonTitle:@"Reset"
destructiveButtonTitle:@"Continue Meeting"
otherButtonTitles:nil];
[actionSheet showFromTabBar:self.tabBarController.tabBar]; // This is the line that crashes. The program checks for a terminated APP and status in preferences
}
else {
resetStuff.hidden = YES;
}
}
Here is the text of the crash -
Current language: auto; currently objective-c
2011-10-12 21:02:55.530 Wasted Time[3884:17603] * Assertion failure in -[UIActionSheet showInView:], /SourceCache/UIKit_Sim/UIKit-1912.3/UIActionSheet.m:4630 2011-10-12 21:02:55.532 APP NAME[3884:17603] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: view != nil' ** First throw call stack: (0x1d87052 0x1f18d0a 0x1d2fa78 0x2742db 0x90b47e 0x90b122 0x90b356 0x90b653 0x6fe1 0x60064e 0x61bb89 0x61b9bd 0x619f8a 0x619e2f 0x617ffb 0x61885a 0x601fbf 0x60221b 0x6030f1 0x571fec 0x577572 0x57172b 0x2b86 0x5389d6 0x5398a6 0x548743 0x5491f8 0x53caa9 0x2315fa9 0x1d5b1c5 0x1cc0022 0x1cbe90a 0x1cbddb4 0x1cbdccb 0x5392a7 0x53aa9b 0x2abd 0x2325) terminate called throwing an exception(gdb
Blockquote
Here's the Delegate .h
#import <UIKit/UIKit.h>
@interface W_AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *rootController;
float floatVal;
NSDate *currentTime;
NSDate *previousTime;
NSDate *currentQTime;
NSDate *previousQTime;
BOOL continueMeeting;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *rootController;
@property (nonatomic, readwrite) float floatVal;
@property (nonatomic, readwrite) BOOL continueMeeting;
@property (nonatomic, retain) NSDate *currentTime;
@property (nonatomic, retain) NSDate *previousTime;
@property (nonatomic, retain) NSDate *currentQTime;
@property (nonatomic, retain) NSDate *previousQTime;
@end
And the .m
#import "W.h"
@implementation W_AppDelegate
@synthesize window;
@synthesize rootController;
@synthesize floatVal;
@synthesize currentTime;
@synthesize previousTime;
@synthesize currentQTime;
@synthesize previousQTime;
@synthesize continueMeeting;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:rootController.view];
[window makeKeyAndVisible];
return YES;
}
@end
Try and call your [super viewDidLoad]; first. Your view probably isn't set up enough to push the actionSheet yet.