flurry to iphone,add details are not opening - iphone

i have integrated flurry to my project and add is displaying successfully.but the problem is when i clicked on the add then its coming like "safari can't open the page",i have used below code,please help me where i went wrong or what will i do?.
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[FlurryAds setAdDelegate:self];
[FlurryAds fetchAndDisplayAdForSpace:#"BANNER_MAIN_VIEW" view:self.view size:BANNER_TOP];
}
-(void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// Reset delegate
[FlurryAds removeAdFromSpace:#"BANNER_MAIN_VIEW"];
}
and in console i am getting like:
webView:shouldStartLoadWithRequest:[http://itunes.apple.com/app/id505821326?partnerId=30&siteID=PIA/JJ6Lt9U]navigationType:5

Related

facebook login using FBloginView not showing in ios 6

i am trying create login button for facebook using FBloginView.
Following is the code i wrote.
- (void)viewDidLoad
{
[super viewDidLoad];
if(!loginview)
loginview = [[FBLoginView alloc] initWithPermissions:[NSArray arrayWithObject:#"publish_actions, user_photos,status_update"]]; // Whatever permissions you need
loginview.frame = self.view.bounds; //whatever you want
loginview.delegate = self;
[self.view addSubview:loginview];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
NSLog(#"Logged In");
}
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSLog(#"user Id %#",user.id);
}
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView {
// Called after logout
NSLog(#"Logged out");
}
but its not showing login button.
what is the problem with my code. in console am getting "Logged out".
I had FacebookSDKResources.bundle added but still I got the error "Unknown class FBLoginView in interface builder" appearing in the xcode output pane.
To fix this I added the following line to didFinishLaunchingWithOptions :
[FBLoginView class];
This is explained in https://developers.facebook.com/ios/login-ui-control/
As noted by #rajath above, the resolution is to add the FacebookSDKResources.bundle to your project.

why do I get "wait_fences: failed to receive reply" for this code?

why do I get "wait_fences: failed to receive reply" for this code? Is it the way I'm using notification to communicate back to the main thread?
#import "ViewController.h"
#implementation ViewController
#synthesize alert;
#pragma mark - Background Thread Test Methods
- (void) ConfigTasksForBackground:(id)sender{
NSLog(#"ConfigTasksForBackground - Starting");
[NSThread sleepForTimeInterval:6];
[[NSNotificationCenter defaultCenter] postNotificationName:#"ModelChanged" object:self];
NSLog(#"ConfigTasksForBackground - Ending");
}
#pragma mark - Callbacks
- (void) ModelChangedHandler:(NSNotification *) notification {
if ([[notification name] isEqualToString:#"ModelChanged"]) {
NSLog(#"ModelChangedHandler");
[self.alert dismissWithClickedButtonIndex:0 animated:false];
}
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(ModelChangedHandler:)
name:#"ModelChanged"
object:nil];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
self.alert = [[[UIAlertView alloc] initWithTitle:#"Title"
message:#"viewDidAppear"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil] autorelease];
[alert show];
[self performSelectorInBackground:#selector(ConfigTasksForBackground:) withObject:nil];
}
#end
Output is:
2011-11-07 15:15:42.730 test_background[6876:13603] ConfigTasksForBackground - Starting
2011-11-07 15:15:48.734 test_background[6876:13603] ModelChangedHandler
2011-11-07 15:15:49.236 test_background[6876:13603] ConfigTasksForBackground - Ending
wait_fences: failed to receive reply: 10004003
There is an obvious problem here. You are posting the notification from the background thread (which is fine) which means the notification handler ModelChangedHandler is being called on the background thread. The handler is then dismissing an alert view which must be done on the main thread. Try changing your code to:
- (void) ModelChangedHandler:(NSNotification *) notification {
if (![NSThread isMainThread]) {
[self performSelectorOnMainThread:#selector(ModelChangedHandler:) withObject:notification waitUntilDone:NO];
}
else if ([[notification name] isEqualToString:#"ModelChanged"]) {
NSLog(#"ModelChangedHandler");
[self.alert dismissWithClickedButtonIndex:0 animated:false];
}
}
EDIT: was typing too fast, changed answer to reflect the correct UI objects.
Here's how to get rid of the wait_fences error. Change the line where you dismiss the alertView to use animation as follows:
[self.alert dismissWithClickedButtonIndex:0 animated:YES];
I think wait_fences has something to do with view animation states with alert views but it's hard to know for sure. I do think this should eliminate the error msg though. My other answer doesn't directly get rid of the error but I still recommend it. UI actions should be done on the main thread.

How to Release Objects initiated in the ViewController

I am filling some Objects from my View Controller using the following Method :
-(void)viewWillAppear:(BOOL)animated
{
}
What's the best way to release the Objects?I want to release all the used Object when my View closes.
Thanks
You should release them after your view has disappeared, not before, otherwise you may see some strange effects if your view disappears with animation...
- (void)viewDidDisappear:(BOOL)animated {
// release here...
[super viewDidDisappear:animated];
}
release them here
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
-(void)viewWillDisappear:(BOOL)animated
{
}

How can i refresh a view every time when a tab bar item is clicked?

I am making an application with TabBar. But TabBarController is not RootViewController. In the Tab Bar there are 4 tabs. One of those tabs is history which is linked with a table view which shows history. I want to refresh that view every time when i click that so that i can get updated tableview. How can i do that? Thanks in advance.
use - (void) viewWillAppear:(BOOL)animated to update any content in your view.
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// You code here to update the view.
}
This method will be called every time the view is about to be displayed.
below code added plz ^^
If you change a tabBarIndex, At the same time -(void)viewWillAppear called.
-(void)viewWillAppear:(BOOL)animated
{
// force the tableview to load
[tableView reloadData];
}
refer a Apple Sample Code: that is amazing great tutorial for you about UITabBarController
http://developer.apple.com/library/ios/#samplecode/TheElements/Introduction/Intro.html
Apple Sample Code is no added [super viewWillAppear:animated];
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:YES];
if ([Globals sharedInstance].isFromFindSimiler)
{
[self.view addSubview:_findSimilerView];
[_historyTableView setFrame:CGRectMake(0, 85, 320, 490)];
}
else
{
[self history_webservice];
}
}
I have achieved this. In this case, whenever user tabs on History screen I call web service for history and update tableview.
instead of using (void)ViewDidLoad use viewWillAppear:(BOOL)animated
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//your code
}

iPhone Shake event not properly working

I have this inside my viewController:
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
NSLog(#"I have shaked");
}
}
Why is this not working?
Edit:
I do infact have this:
- (void) viewWillAppear:(BOOL)animated
{
[shakeView becomeFirstResponder];
[super viewWillAppear:animated];
}
- (void) viewWillDisappear:(BOOL)animated
{
[shakeView resignFirstResponder];
[super viewWillDisappear:animated];
}
If the UIViewController is loaded at the very start of the application, I've seen an odd glitch in OS 3.0 where it would not become the first responder unless you delayed the appropriate message a bit. Try placing
[self performSelector:#selector(becomeFirstResponder) withObject:nil afterDelay:0.3];
within -loadView or something else that is called when the controller is first set up.
There may be a more elegant way to work around this, but this approach has worked for me.
The viewController must be the first responder during the shake to receive this event.
This could be one reason it's not working.