简体   繁体   中英

hide keyboard in ios7

In my App I am doing registartion through the Twitter. so user can register into my app through the twitter. I want to show Alertview if user has not set account in settings. so user can navigate to settings for add twitter account. also i do not want to show keyboard which appears with SLComposeViewController . for this I used below code

SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    tweetSheet.view.hidden=TRUE;

    [self presentViewController:tweetSheet animated:NO completion:^{
        [tweetSheet.view endEditing:YES];

    }];

in ios6 above code hides the SLComposeViewController & keyboard & shows the alertView that user not has twitter account. & after clicking on settings button of alertView it navigates to settings in phone.

BUT in iOS7 , above code shows the keyboard & does not navigate to settings after clicking on settings button.

so my question is -Why this happening . it works in ios6 but not in ios7. diffrent behaviour in different version

Yes I solved this problem. see below code

SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]

       [self presentViewController:tweetSheet animated:NO completion:^{
           [self dismissModalViewControllerAnimated:NO];
    }];

for showing alertView with settings option I presented tweetSheet, if user already not added any account then it shows alertView With settings option. because it is alertView it does not enter completion (completion:^{ }) area until we press any button of alertView. once you pressed anyone button then it enters into completion area & it dismisses tweetSheet thats why it does not shows keyboard.

You can go to setting ->Facebook via pressing alert dialog button in your app if user is not logged in Facebook account below iOS 5.1. but i think this functionality has been removed by Apple in iOS 6 or more version.(same problem with me )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM