Logout of Facebook in app using Facebook ios SDK
For logout you should try this
you can add the Logout button on Navigation Controller (Top Right Corner) in viewDidLoad method
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered target:self action:@selector(logoutButtonWasPressed:)];
and the action method for above added button is
-(void)logoutButtonWasPressed:(id)sender { [FBSession.activeSession closeAndClearTokenInformation];}
Hope this will help you!
Edit:
As you asked why its not asking for UserName and Password,So the reason is :
When we integrate Facebook SDK in our app and try to login, it automatically check two places (to make sure we have already logged-in Facebook or not)
First of all It checks whether we have already logged-in into Facebook Native app which is installed on this device.
then It checks whether we have saved our FaceBook UserName and Password in Device Settings.
If both places we haven't logged-in then It will ask UserName and Password in application
you can check Facebook account setup in Device Settings as shown in below screen shot,
Press Home Button --> Settings -->Facebook