ios - How to dismiss the UIAlertview on the click of UIViewController or on the UIScrollView in objective c -
i new in ios , facing problem regarding dismiss uialertview. showing image in uialertview , using long press gesture call alertview. code this
imagename.userinteractionenabled=yes; uilongpressgesturerecognizer *longpressgesturerecognizer = [[uilongpressgesturerecognizer alloc] init]; [longpressgesturerecognizer addtarget:self action:@selector(imglongpressed:)]; longpressgesturerecognizer.delegate = self; [imagename addgesturerecognizer: longpressgesturerecognizer]; - (void) imglongpressed:(uilongpressgesturerecognizer*)sender { uiimageview *imageview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, 200, 282)]; uiimage *wonimage = imagename.image; imageview.contentmode=uiviewcontentmodecenter; [imageview setimage:wonimage]; alertview = [[uialertview alloc] initwithtitle:@"" message:@"" delegate:self cancelbuttontitle:nil otherbuttontitles:@"ok", nil]; //check if os version 7 or above if (floor(nsfoundationversionnumber) > nsfoundationversionnumber_ios_6_1) { [alertview setvalue:imageview forkey:@"accessoryview"]; }else{ [alertview addsubview:imageview]; } [alertview show]; [self performselector:@selector(dismiss:) withobject:alertview afterdelay:1.0]; } -(void)dismiss:(uialertview*)alert { [alert dismisswithclickedbuttonindex:-1 animated:yes]; }
this code give me output image
i need dismiss uialertview on touch of uiviewcontroller or uiscrollview.
uialertview
depreciated. not advised use depreciated elements since might cause problems latest versions of ios. given functionality, think it's better use thirdparty alertviews one: https://cocoapods.org/pods/sclalertview-objective-c
Comments
Post a Comment