i have used below code show action sheet tweet, facebook , cancel button.
- (void)shareapp:(id)sender { nsstring *strcancel = nslocalizedstring(@"cancel", nil); nsstring *strtweet = nslocalizedstring(@"tweet", nil); nsstring *strfacebook = nslocalizedstring(@"facebook", nil); uialertcontroller *alertcontroller = [uialertcontroller alertcontrollerwithtitle:nslocalizedstring(@"share app", nil) message:nil preferredstyle:uialertcontrollerstyleactionsheet]; // create actions. uialertaction *cancelaction = [uialertaction actionwithtitle:strcancel style:uialertactionstylecancel handler:^(uialertaction *action) { nslog(@"cancel action occured"); }]; uialertaction *tweetaction = [uialertaction actionwithtitle:strtweet style:uialertactionstyledefault handler:^(uialertaction *action) { nslog(@"tweet action here"); }]; uialertaction *facebookaction = [uialertaction actionwithtitle:strfacebook style:uialertactionstyledefault handler:^(uialertaction *action) { nslog(@"facebook action here"); }]; // add actions. [alertcontroller addaction:cancelaction]; [alertcontroller addaction:tweetaction]; [alertcontroller addaction:facebookaction]; [self presentviewcontroller:alertcontroller animated:yes completion:nil]; }
now, want add custom view i.e. logo + tweet on each element of action sheet.
how can implemented?
i got solution through code.just refer below coding
nsstring *strcancel = nslocalizedstring(@"cancel", nil); nsstring *strtweet = nslocalizedstring(@"tweet", nil); nsstring *strfacebook = nslocalizedstring(@"facebook", nil); uialertcontroller *alertcontroller = [uialertcontroller alertcontrollerwithtitle:nslocalizedstring(@"share app", nil) message:nil preferredstyle:uialertcontrollerstyleactionsheet]; uialertaction *cancelaction = [uialertaction actionwithtitle:strcancel style:uialertactionstylecancel handler:^(uialertaction *action) { nslog(@"cancel action occured"); }]; uialertaction *tweetaction = [uialertaction actionwithtitle:strtweet style:uialertactionstyledefault handler:^(uialertaction *action) { nslog(@"tweet action here"); }]; uialertaction *facebookaction = [uialertaction actionwithtitle:strfacebook style:uialertactionstyledefault handler:^(uialertaction *action) { nslog(@"facebook action here"); }]; uiimage *accessoryimage = [uiimage imagenamed:@"twitter.jpg"]; [tweetaction setvalue:accessoryimage forkey:@"image"]; uiimage *accessoryfbimage = [uiimage imagenamed:@"facebook.png"]; [facebookaction setvalue:accessoryfbimage forkey:@"image"]; [alertcontroller addaction:tweetaction]; [alertcontroller addaction:facebookaction]; [alertcontroller addaction:cancelaction]; [self presentviewcontroller:alertcontroller animated:yes completion:nil];
Comments
Post a Comment