Reputation: 1773
I am using a custom class very similar to the Tweet Bot info panels in my application. I have this class working perfectly when a button is tapped, however what I am trying to achieve is getting this 'alert panel' to show when my application finishes launching or comes from being idle.
To call this class using a standard I am using the following code;
-(IBAction) button1Tapped:(id) sender
{
[MKInfoPanel showPanelInView:self.view
type:MKInfoPanelTypeInfo
title:@"Tweet Posted!"
subtitle:nil
hideAfter:2];
}
But I am having issues including this in my main AppDelegate.m. I keep getting an error message of 'Property type view not found in Total_HealthAppDelegate when i use the following;
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[MKInfoPanel showPanelInView:self.view
type:MKInfoPanelTypeInfo
title:@"Total:Health Support"
subtitle:@"Welcome"
hideAfter:3];
}
Any advice would be great
Upvotes: 0
Views: 1052
Reputation: 48398
Try using self.window
in place of self.view
when this code is inside the AppDelegate. Also be sure to include the appropriate header files and declare the class.
However, I recommend you put this code into the viewController that first wakes up instead. Here's one way to accomplish this.
Set up a BOOL
in NSUserDefaults
called justWokeUp
. Then, in the appDelegate, set it to YES
when the app wakes up:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
[standardUserDefaults setBool:YES forKey:@"justWokeUp];
}
Now, in any viewController that might be the first to load when the app resumes, check this value to see whether you should send the alert:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
if ([standardUserDefaults boolForKey:@"justWokeUp"]) {
[MKInfoPanel showPanelInView:self.view
type:MKInfoPanelTypeInfo
title:@"Total:Health Support"
subtitle:@"Welcome"
hideAfter:3];
[standardUserDefaults setBool:NO forKey:@"justWokeUp"];
}
Upvotes: 1