I am using FBLogInView to implement FBLogin. loginViewFetchedUserInfo not getting called - iphone

I have spent several hours. Read up everything relevant I could find on the web, but haven't been able to resolve this. I am using FBLoginView per instructions provided in https://developers.facebook.com/docs/ios/login-ui-control/
I can see FBLogin button. I click on it. It logs me in. I see callbacks loginViewShowingLoggedInUser and loginViewShowingLoggedOutUser getting called. The problem is loginViewFetchedUserInfo not getting called. So, I am unable to get any information about the user (such as name, userID, email etc).
Here is the code I am using:
CGRect loginFrame=CGRectMake(MARGIN,currentFrame.size.height-LOGINBUTTONHEIGHT,50 , 20);//width, height don't matter
FBLoginView * FBLoginView1 = [[FBLoginView alloc] init];
FBLoginView1.readPermissions = #[#"email",
#"basic_info",
#"user_location",
#"user_birthday",
#"user_likes"];
FBLoginView1.frame = loginFrame;
FBLoginView1.delegate = self;
[[self view] addSubview:FBLoginView1];
[FBLoginView1 sizeToFit];
Please help me.

It may help: I have get the same issue. For me the solution was I did not correctly assign the delegate.
Programmatically, Facebook propose you to
FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.delegate = self;
But as I have set up the view via the storyboard, I could not do that. So in the inspector connector, I connect the delegate outlet to the File's Owner (I just wired the outlet the scene).
Hope it helps :)

I found the solution. Actually, loginViewFetchedUserInfo is called after loginViewShowingLoggedInUser. I was not getting loginViewFetchedUserInfo because I was dismissing modalviewcontroller from loginViewShowingLoggedInUser. So, it was not around to get loginViewFetchedUserInfo. If I don't dismiss the modalviewcontroller, I get loginViewFetchedUserInfo.
Here are the details of the solution.
I am creating FBLoginView in ViewDidLoad of a LoginViewcontroller (name of the class I implemented).
I set the delegate when I create FBLoginView (inside ViewDidLoad function)
LoginViewController is presented using presentViewController function.
The problem was happening because I was dismissing the view controller in loginViewShowingLoggedInUser. So it was not around to receive loginViewFetchedUserInfo ( loginViewFetchedUserInfo is called after loginViewShowingLoggedInUser).
The solution that worked for me is to dismiss LoginViewcontroller from loginViewFetchedUserInfo.
Hope the details helps others.

I had the same problem. In my case, delegate was not set properly. Ensure you the following lines in logincontroller:
FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.delegate = self;

Related

Adding a pull to refresh feature to UIWebView iOS

I'm looking to add a Pull to refresh feature to a UIWebView that I have in an app. I've used Pull to refresh in the past on table views, but I'm struggling to find any good tutorials/libraries to help me add it to UIWebViews specifically and this project.
I did get some of the way using PullToRefreshView by chpwn (https://github.com/chpwn/PullToRefreshView) but I can't get it detecting the drag.
Does anyone know a better plug in/library?
For me this post and code worked like a charm
http://sonnyparlin.com/2011/12/pulltorefresh-ios-5-and-arc-tutorial/
I'm new to iOS development, so this may not be the best way… but it worked for me.
I took the controller that was wrapping my WebView and I changed it to a UITableViewController (it was just a UIViewController previously) so that I could take advantage of the refreshControl property of that controller (ios6 and up). I'm not making use of the TableView inside of the UITableViewController (though, it does seem to require one to exist, which I include, but I just don't populate it). I added 2 methods to the controller:
- (void)addPullToRefresh
{
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:#"Pull to Refresh"];
[refreshControl addTarget:self.myWebView action:#selector(reload)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
}
- (void)stopRefresh
{
[self.refreshControl endRefreshing];
}
I put a call to [self addPullToRefresh]; in viewDidLoad, and I added a call to [self stopRefresh]; in webViewDidFinishLoad:
I got my instructions for how to use the refreshControl property of UITableViewController here.

UINavigationController strange crash

I'm having a strange problem with my UINavigationController. the stacktraces are:
which is very odd to me because all I did was:
CommonVC* cvc = [[CommonVC alloc] init];
//CommonVC is my customized viewController. and i did some setting after the init.
[self.navigationController pushViewController:cvc animated:TRUE];
[cvc release];
and after 3 times pushing and popping it crashes.
i also ran it with NSZombie but it told the zombie is the CommonVC itself.
so can anyone help me find where the problem would be?
Do you make use of delegates and set them in your view controller. If yes check if they are made nil...

Previous View after dismissModalViewControllerAnimated of email function somehow defect

i am trying and trying.... but no result yet.
i have a view with a navigationcontroller and -bar. in addition there is a tableview.
if you click on a row, the iphone email function is getting startet by using the email example from apple (MailComposerViewController.h and .m).
it opens and i am able to send or cancel the mail. after that the "dismissModalViewControllerAnimated" methode is dismissing the emailing view. everything looks right, i am in the previous view now, BUT:
when i want to use buttons from the navigationitem or if i want to add rows to the tableview, the app is crashing without any error message.
do i have to set something back or to "remove" something which is still there because of the mailing view?
it's really strange and i am searching now for hours....... :-(
thank you very much in advance!
hopefully someone has an idea.
EDIT:
ok, here i have the code now:
in a tableview which is included in a navcontroller i have following lines to open first a Subclass of UIViewController:
- (IBAction)Action:(id)sender
{
DetailViewController *editViewController = [[DetailViewController alloc] initWithNibName:#"TripDetailViewController" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:editViewController animated:YES];
editViewController.navigationItem.prompt = #"Details";
[editViewController release];
}
in the DetailViewController following action is processed when the user clicks on the button:
- (IBAction)mailTrip:(id)sender {
MailComposerViewController *mailComposer = [[MailComposerViewController alloc] init];
[[[self view] window] addSubview:[mailComposer view]];
[mailComposer showPicker:sender];
}
when i press the related button, the MailComposerViewController pushes up correctly. all functions of the MailComposerViewController are working correct.
but when i send or cancel the mail and the MailComposerViewController disappears, my previous view doesn't work anymore.
in the MailComposerViewController-Example from apple the MailComposerViewController just disappear and the previous view is working fine again.... :-(
ok, i found the stupid simple problem.
the MailComposer-View was after dismissing it still over the previous view.
i did set the propert hidden after dismissing and now it works...
[self dismissModalViewControllerAnimated:YES];
[[self view] setHidden:YES];
but i am really not sure if this is the right way to do it...

App stalls - no crash, no error

It is worth noting that this part of the app (this option from the main menu) was working perfectly before. I then programmed the next option from the main menu, and now this one is not working anymore.
I know the code I've written works, but there is something wrong with either the class or the xib, because it worked when I switched it to call a different class/xib from:
UIViewController *nextController = [[OneMethodController alloc] initWithNibName:#"OneMethodController" bundle:nil];
to:
UIViewController *nextController = [[SecondMethodController alloc] initWithNibName:#"SecondMethodController" bundle:nil];
When I try to load the first class/xib (which used to work, as I said), the app just stalls indefinitely. There is no error and the app does not crash.
Any ideas? THANKS!!
Note that *nextController should most likely be initialized as
SecondMethodController *nextController = [[SecondMethodController alloc] init . . .
And not as
UIViewController *nextController = [[SecondMethodController alloc] init . . .
The issue was not with the XIB but with the viewDidLoad of that XIB's class. Thanks #cool_me5000 for your help with this.

Strange Exc Bad Access when using Init, PushViewController, Release. Anything wrong with this code?

Maybe I've been looking at this for too long ;) My app has a NavigationController and several ViewControllers. From one of the ViewControllers two levels down (mainViewController), loaded from the rootViewController, I have the code below. After the PushViewController to the dataViewController and back (e.g. back Button pressed), the app crashes.
The dataViewController loads just fine, but when the back button of the navigationController is tapped, the App crashes with Object Exception. If I remove:
[dataViewController release];
the app works fine. It's strange because the dataViewController is init'ed in the same method.
Any ideas?
- (void) locationPage
{
[[NSNotificationCenter defaultCenter] postNotificationName:#"NotifyRemoveMap" object:nil];
MyAppDelegate *app = [[UIApplication sharedApplication] delegate];
UINavigationController *navigation = app.navigationCantroller;
[navigation popToRootViewControllerAnimated:NO];
DataViewController *dataViewController = [[DataViewController alloc] initWithNibName:#"DataView" bundle:nil];
[dataViewController setCategoryId:category];
MyLanguage *lang = app.lang;
Mylocation *location = [lang locationForCategoryId:category];
dataViewController.title = location.name;
NSArray *locationArray = [lang locations];
dataViewController.locations = locationArray;
[navigation pushViewController:dataViewController animated:YES];
[dataViewController release]; // With this removed, app doesn't crash
}
Haven't even read your post. If it's Exec-Bad-Access, I have 2 words for you:
Enable NSZombies.
Follow this link: (it explains everything you need to know to fix any bad access issue)
Phone Memory Debug with NSZombie and Instruments
Cheers!
The problem probably arises when the dataViewController gets popped and you try to access something on it - it is already released then. You might check the console for more details - better yet, run in debug mode (debug configuration and running with debugger).
You can edit your question to show some code that is run with the back button.
You talk about releasing dataViewController but your code says detailsViewController. Did you copy and paste incorrectly or is that the mistake?
You should consider not to use app.navigationController but self.navigationController. Cleaner design. Less dependencies on the app delegate, which too often is used as a frankensteinobject that knows too much.