ios - Image insides UIBubbleTableView -
i making ios chat app. use uibubbletableview
display texts , images.
now ,i want image can click , move view (which people can see in full size). uibubbletableview
seems doesn't support it, how can fix it?
here code in viewdidload:
- (void)viewdidload { //something here// [super viewdidload]; nsbubbledata *photobubble = [nsbubbledata datawithimage:[uiimage imagenamed:@"halloween.jpg"] date:[nsdate datewithtimeintervalsincenow:-290] type:bubbletypesomeoneelse]; //something else here// }
with these codes shows image.
i know isn't recommended or ideal way it, have done time being. come , "correctly" later when find way.
for each nsbubbledata object, add touch gesture it's view. when user touches, toucheventonimage:
method called. sender, can gesture recognizer, view of uiimageview set nsbubbledata. can display image full screen.
this code used:
- (void)addtouchgesturetobubble:(nsbubbledata *)obubbledata { uitapgesturerecognizer * taprecognizer = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(toucheventonimage:)]; [taprecognizer setnumberoftouchesrequired:1]; //don't forget set userinteractionenabled yes, default it's no. obubbledata.view.userinteractionenabled = yes; [obubbledata.view addgesturerecognizer:taprecognizer]; } - (void)toucheventonimage:(id)sender { if( [sender iskindofclass:[uigesturerecognizer class]] ) { uigesturerecognizer * recognizer = (uigesturerecognizer *)sender; if( [recognizer.view iskindofclass:[uiimageview class]] ) { uiimageview * imageview = [[uiimageview alloc] initwithimage:((uiimageview *)recognizer.view).image]; imageview.contentmode = uiviewcontentmodescaleaspectfit; imageview.frame = cgrectmake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height); imageview.backgroundcolor = [uicolor blackcolor]; // remove corner radius applied in nsbubbledata class. imageview.layer.cornerradius = 0.0; uiviewcontroller * vc = [[uiviewcontroller alloc] init]; vc.view = imageview; [self.navigationcontroller pushviewcontroller:vc animated:yes]; } } }
i hope helps @ least make progress.