Passing data between UITableViewCell and UITableViewController?

前端 未结 2 1972
野性不改
野性不改 2021-01-20 17:00

I created master details template project in xcode 4.6 and I added custom cell with 2 textfields. I also created new class which is subclass of UITableViewCell and inside th

2条回答
  •  一整个雨季
    2021-01-20 17:45

    In your case you need to create Protocol:

    I just Give Basic Idea for how to Create Protocol

    Also Read This Question

    #DetailViewController.h
    
    #import 
    
    @protocol MasterDelegate 
    -(void) getButtonTitile:(NSString *)btnTitle;
    @end
    
    
    @interface DetailViewController : MasterViewController
    
    @property (nonatomic, assign) id customDelegate; 
    
    #DetailViewController.m
    
    if([self.customDelegate respondsToSelector:@selector(getButtonTitile:)])
    {
              [self.customDelegate getButtonTitile:button.currentTitle];    
    }
    
    #MasterViewController.m
    
    create obj of DetailViewController
    
    DetailViewController *obj = [[DetailViewController alloc] init];
    obj.customDelegate = self;
    [self.navigationController pushViewController:reportTypeVC animated:YES];
    
    and add delegate method in MasterViewController.m for get button title.
    
    #pragma mark -
    #pragma mark - Custom Delegate  Method
    
    -(void) getButtonTitile:(NSString *)btnTitle;
    {
        NSLog(@"%@", btnTitle);
    
    }
    

提交回复
热议问题