flurryads crash when presenting uiactionsheet - flurry

I'm using GoogleAdMobAds in my application to show ads. GoogleAds (somehow) has a reference to flurry ads. (GoogleAdMobAds - version 6.5.0, FluttyAds version 4.3.1.a).
ViewController has a tableView that contains GADBannerView.
Here is my code.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
GADAdSize adSize = [self adSizeForOrientation:self.interfaceOrientation];
self.adview = [[GADBannerView alloc] initWithAdSize:adSize];
self.adview.adUnitID = ADMOB_APP_KEY;
self.adview.rootViewController = self;
self.adview.backgroundColor = [UIColor clearColor];
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
request.gender = kGADGenderMale;
[request setLocationWithLatitude:[userDefaults doubleForKey:#"lat"]
longitude:[userDefaults doubleForKey:#"lng"]
accuracy:kCLLocationAccuracyBest];
self.adview.delegate = self;
[self.adview loadRequest:request];
So the application crashes when i present uiactionsheet, before
- (void)adViewDidReceiveAd:(GADBannerView *)bannerView
calls.
I tried to avoid delegate and rootViewController in GADBannerView before actionsheet present, but all my efforts were in vain.

The problem lays in view controllers hierarchy. I added view controller to window.rootViewController by just addSubview:, after i add [rootViewController addChildViewController:] crash disappears.

Related

Data Persistence with CoreData

Hi everybody I have a problem using CoreData Persistence, my problem is, when I launch my application I manage to add some data (from a form within the app) to my DataBase and display them with using NSLog.
But actually I think all these data disappear when I stop the ipad emulator and re launch it after..
So i don't really know if it comes from my code or if it's because of the emulator.
I made a diagram to show you the architecture of my app and my entities:
The problem is that i'm using different viewController so i need to pass the ManagedObjectModel to each one. My form is in the newDocumentViewController, when i add somme entities i would like to access them in all the others viewController and save it to the app local storage.
Here is some code to show you a bit:
AppDelegate.m
#synthesize managedObjectContext = __managedObjectContext;
#synthesize managedObjectModel = __managedObjectModel;
#synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:#"DetailViewController" bundle:nil];
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:#"MasterViewController" bundle:nil];
UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
masterViewController.managedObjectContext = self.managedObjectContext;
detailViewController.managedObjectContext = self.managedObjectContext;
I have those properties within each masterViewController and DetailViewController (and from DetailViewController to NewDocumenViewController) to receive the objectContext
#property (nonatomic,strong) NSManagedObjectContext *managedObjectContext;
So with this i don't really know how to access my data from each controller and is the data is stored locally by doing like this:
NewDocumentController.m
-(void) addNewDocument:(NSString*)name with_niveau:(NSInteger)level{
Document *doc = [NSEntityDescription insertNewObjectForEntityForName:#"Document" inManagedObjectContext:managedObjectContext];
doc.nom=name;
doc.niveau=[NSNumber numberWithInteger:level];
}
-(void) addNewDocument_info:(NSString*)name with_createur:(NSString*)createur with_dateModif:(NSDate*)date1 with_status:(BOOL)etat{
DocumentInfo *doc_info = [NSEntityDescription insertNewObjectForEntityForName:#"DocumentInfo" inManagedObjectContext:managedObjectContext];
doc_info.nom =name;
doc_info.createur=createur;
doc_info.date_creation=[NSDate date];
doc_info.date_modification=date1;
doc_info.status= [NSNumber numberWithBool:etat];
}
You need to save your data:
NSError *error = nil;
[self.managedObjectContext save:&error];

UIPickerView Selectrow inComponent Not responding

I've a view part of tab bar controller. I've added a UIpickerview to the View. The delegate and data source of the uipickerview is the viewcontroller.
I've a coded like this
- (void)viewDidLoad{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"bg.png"]];
self.arrCurrencies = [[NSMutableArray alloc] init];
[self.arrCurrencies addObject:#"USD"];
[self.arrCurrencies addObject:#"GBP"];
[self.arrCurrencies addObject:#"INR"];
[self.arrCurrencies addObject:#"EUR"];
[self.arrCurrencies addObject:#"YEN"];
[self.arrCurrencies addObject:#"AUD"];
[self.arrCurrencies addObject:#"SGD"];
[self.pickerView reloadAllComponents];
[self.pickerView selectRow:2 inComponent:0 animated:NO];
}
I tried the above code, it's not selecting the 3rd row or INR in the pickerview by default. Can someone suggest me where I'm wrong..!
I don't see your .delegate method, but make sure you have it in this order:
mypicker.delegate = self;
[mypicker selectRow:[[General sharedInstance] displayMode] inComponent:0 animated:YES];
I had the delegate call method after the 'selectRow' method and I was mad looking for the solution in internet. 2 days with a lot of solutions, and only was this!!!
So, this doesn't work:
[mypicker selectRow:[[General sharedInstance] displayMode] inComponent:0 animated:YES];
mypicker.delegate = self;
A hint: My class is UIViewController child.

UIAlertView showing up very slowly

I just wrote a iOS app to test the UIAlertView. When I ran it, the UIAlertView just appear with the screen went dark first without the UIAlertView, and "a long time" later ,the UIAlertView appeared. This happens on both Simulator and iPhone (IOS 4.2). I don't know why, Please help me, thanks.
Description:(You can also download the Project HERE)
Its a very simple View based app With 3 Classes: AppDelgate ViewControler and a TestOperation which implement NSOperation;
AppDelegate was just the one produced by XCode;
TestOperation.h:
#import <Foundation/Foundation.h>
#protocol TestOperationDelegate
- (void)didFinishTestOperaion;
#end
#interface TestOperation : NSOperation {
id <TestOperationDelegate> delegate;
}
#property (nonatomic, assign) id <TestOperationDelegate> delegate;
#end
TestOperation.m
#import "TestOperation.h"
#implementation TestOperation
#synthesize delegate;
- (void)main {
[delegate didFinishTestOperaion];
}
#end
ViewContoller.m
- (void)viewDidLoad {
[super viewDidLoad];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
TestOperation *testOperation = [[TestOperation alloc] init];
testOperation.delegate = self;
[queue addOperation:testOperation];
[testOperation release];
}
- (void)didFinishTestOperaion {
NSLog(#"start uialertview");
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Oops!" message:#"Here's the UIAlertView"
delegate:self cancelButtonTitle:#"Confirm" otherButtonTitles:nil];
[alert show];
[alert release];
}
//Solved!! Use performSelectorOnMainThread to make
the UI run on Main Thread
Solved!! Use performSelectorOnMainThread to make the UI run on Main Thread
[alert performSelectorOnMainThread:#selector(show) withObject:nil waitUntilDone:NO];
What are you attempting to test in the UIAlertView? If you simply called the UIAlertView from viewDidAppear: in your ViewController, is the UIAlertView displayed rapidly as expected?
I expect that the issues you are having are related to how you are calling the UIAlertView, and that the UIAlertView is being displayed before the UIView controlled by your ViewController has appeared.

uitabbarcontroller / uitabbar in navigation based project

I have created navigation based project. and in second screen i want to add uitabbarcontroller. so can any one suggest how i do this.
i already did lot of search but no success yet. so please can you provide a simple sample of this. i already tried below discussion but i think its not a good approach.
Navigation Based Application with TabBar
Thanks
Actually this is the correct approach. The one thing that is not correct is where the controllers are allocated. This is happened in the previous controller, the one that is making the push, but should be allocated in the object that is responsible, the TabBarController.
When you implement your action to show the UITabBarController make the following code:
- (void) theAction {
SomeTabBarControllerSubClass *controller = [[SomeTabBarControllerSubClass alloc] init];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
Then when you implement the SomeTabBarControllerSubClass class:
(.h)
#interface SomeTabBarControllerSubClass : UITabBarController {
UIViewController *first;
UIViewController *second;
}
#end
(.m)
#implementation SomeTabBarControllerSubClass
- (void) viewDidLoad {
first = [[UIViewController alloc] init]; //Or initWithNib:
second = [[UIViewController alloc] init];
first.view.backgroundColor = [UIColor greenColor] //Just example
second.view.backgroundColor = [UIColor redColor] //Just example
first.tabBarItem.image = [UIImage imageNamed:#"someImage.png"];
self.viewControllers = [NSArray arrayWithObjects:first,second,nil];
}
- (void) dealloc {
[first dealloc];
[second dealloc];
[super dealloc];
}
#end

Randomly crashing UITableView

I have a UITableView with a Custom Cell, (includes a uiimage generated from a website) and when I select a row it takes me to a detail view. Now if I click on a row as soon as the view loads, sometimes the app will crash. Sometimes when I return to the main tableview from the detail view the app will crash. I am not going to paste my code yet because I honestly have no idea what I would even need to post.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
selectedItems = [[stories objectAtIndex: storyIndex] objectForKey: #"title"];
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:#"DetailView" bundle:[NSBundle mainBundle]];
dvController.imageArray = images;
dvController.selectedItems = selectedItems;
dvController.indexpath = storyIndex;
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:#"CustomCell"owner:self options:nil];
cell = customCell;
self.customCell = nil;
}
// Configure the cell.
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
cell.title.text = [[stories objectAtIndex: storyIndex] objectForKey: #"title"];
[cell.webview loadHTMLString:[NSString stringWithFormat:#"<html><body>%#</body></html>", [images objectAtIndex:indexPath.row]] baseURL:nil];
//NSLog(#"%#", [images objectAtIndex:indexPath.row]);
return cell;
}
The NSLog report says
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayerArray bannerView:didFailToReceiveAdWithError:]: unrecognized selector sent to instance 0x1bcd70'
The didFailToReceiveAdWithError method is below
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
The error you're getting...
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayerArray bannerView:didFailToReceiveAdWithError:]: unrecognized selector sent to instance 0x1bcd70'
...is fairly clear. It's nothing to do with the UITableView and everything to do with the fact that you've not implemented the bannerView:didFailToReceiveAdWithError: method in your ADBannerViewDelegate.

Resources