-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath
{
Dljoblogtableviewcell *cell = [TableView dequeuereusablecellwithidentifier:@ "Othercell"];
Worklogdatamodel * model = [Self.dataarray ObjectAtIndex:indexPath.row];
[Cell Setup:model];
//Add long press gesture to cell
Uilongpressgesturerecognizer * longpressgesture = [[Uilongpressgesturerecognizer alloc]initwithtarget:self action:@ Selector (celllongpress:)];
[Cell addgesturerecognizer:longpressgesture];
[Longpressgesture release];
return cell;
}
#pragma mark---Long press some implementation methods related to replication forwarding
//This method must be implemented, otherwise the president will not display after pressing
-(BOOL) Canperformaction: (SEL) Action Withsender: (ID) sender
{
if (action = = @selector (handlecopyandsendroomcell:) | | Action [email protected] (Handlecopycell:))
{
return YES;
}
return NO;
}
-(void) Celllongpress: (Uigesturerecognizer *) recognizer{
if (recognizer.state = = Uigesturerecognizerstatebegan) {
Cgpoint location = [recognizer LocationInView:self.tableView];
Nsindexpath * Indexpath = [Self.tableview indexpathforrowatpoint:location];
Worklogdatamodel * model = (Worklogdatamodel *) [Self.dataarray ObjectAtIndex:indexPath.row];
NSDate * timedate = [Utils dateTimeToDate:model.createDate];
NSString * time = [self titlefromdate:timedate];
Membermodel *member = [Utilsforum getMemberModelWithPhone:model.phone orwithumid:0];
[Uipasteboard generalpasteboard].string = [NSString stringwithformat:@ ' title:%@\n content: \n%@\n from [%@] work log ', time,model.msg , Member.name];
if (Indexpath!=nil) {
Dljoblogtableviewcell *cell = (Dljoblogtableviewcell *) Recognizer.view;
//This cell is the first response (the cell default is unable to become a responder, you need to override the Canbecomefirstresponder method)
[Cell Becomefirstresponder];
UIMenuItem *itcopy = [[UIMenuItem alloc] initwithtitle:@ "forward to group" action: @selector (Handlecopyandsendroomcell:)];
UIMenuItem *itdelete = [[UIMenuItem alloc] initwithtitle:@ "copy" Action: @selector (Handlecopycell:)];
Uimenucontroller *menu = [Uimenucontroller Sharedmenucontroller];
[Menu Setmenuitems:[nsarray Arraywithobjects:itcopy,itdelete,nil];
[Menu SetTargetRect:cell.frame InView:cell.superview];
[Menu Setmenuvisible:yes Animated:yes];
[Itcopy release];
[Itdelete release];
}
}
}
//Turn on the response of long press replication forwarding------This method is implemented in a custom cell
-(BOOL) canbecomefirstresponder{
return YES;
}
-(void) Handlecopyandsendroomcell: (ID) sender
{
D ("%@", [Uipasteboard generalpasteboard].string);
Discussiongroupcontroller * ADGC = [[Discussiongroupcontroller alloc]init];
adgc.joblogstring = [Uipasteboard generalpasteboard].string;
[Utils PUSHVIEWCONTROLLER:ADGC Animated:yes];
[ADGC release];
}
-(void) Handlecopycell: (ID) sender
{
D ("%@", [Uipasteboard generalpasteboard].string);
}
Add long press forwarding, copy, and other functions to TableView's cell