0
votes

I have a strange problem,

I am trying to display UIActionSheet on a UIWindow object using:

[[UIApplication sharedApplication] keyWindow];

The following code rises view != nil assertion failure

UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];

if(mainWindow != nil)
    [menuUIActionSheet showInView:mainWindow];

The above fails under iOS 4.3 and under iOS 5.0 is valid.

* Assertion failure in -[UIActionSheet showInView:], /SourceCache/UIKit_Sim/UIKit-1448.89/UIActionSheet.m:4402

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: view != nil'

2

2 Answers

0
votes

Probably you have to pass a real UIView instance. You could try to use [[UIApplication sharedApplication] keyWindow].rootViewController.view instead.

0
votes

in

@interface AppDelegate : UIResponder 

make the property

@property (strong, nonatomic)   UIWindow *window;


@implementation AppDelegate

@synthesize window = _window;

then use

AppDelegate.window