A.Kumawat
A.Kumawat

Reputation: 103

TableviewCell select and Move to another view

I used a MBCalendarKit. This is an event shown on tableView method - (void)calendarView:(CKCalendarView *)CalendarView didSelectEvent:(CKCalendarEvent *)event. This method works same as - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath. I want to call the method didSelectEvent on tableView cell click event. How to move to another view controller on cell click ?and pass cell array data. How is it possible? Please help. Thank You

Method

- (void)calendarView:(CKCalendarView *)CalendarView didSelectEvent:(CKCalendarEvent *)event
{
 //  A row is selected in the events table. (Use to push a detail view or whatever.)
 CalendarViewController*destVC = [[CalendarViewController alloc] init];
destVC.pure=arr;
[self presentViewController:destVC animated:YES completion:nil];

}

Upvotes: 2

Views: 471

Answers (2)

Moshe
Moshe

Reputation: 58087

If you’re implementing CKCalendarViewDelegate, or subclassing CKCalenderViewController, from inside calendarView:didSelectEvent:, you can push a new view controller onto the navigation stack, or present it yourself, with presentViewController:animated:completion:.

If you want to pass the event through to the second view controller, assign it as a property before presenting or pushing the view controller.

Disclosure: I’m the author of MBCalendarKit.

Upvotes: 0

Meet
Meet

Reputation: 1206

In tableview didSelectRowAtIndexPath Method :-

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

call your function :-

[self didSelectEvent:..

Also to move to another view controller use segue as follows in same didSelectRowAtIndexPath Method of tableView:-

[self performSegueWithIdentifier:@"segueName" sender:self];

Finally, to pass cell array use prepareForSegue:-

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"segueName"])
    {

        DestViewController *dest = segue.destinationViewController;
        dest.passedArr = Arr;

    }
}

Note:- "segueName" needs to be defined in Storyboard

Upvotes: 0

Related Questions