How to pass data back from detail view controller to uitableview?

前端 未结 2 798
长发绾君心
长发绾君心 2021-02-06 10:45

In my app i making use of uitable to select category from my list. my task is,when ever user click or select a cell he should be able to view the selected cell detail in next vi

2条回答
  •  半阙折子戏
    2021-02-06 11:13

    You need to make use of custom delegates. Create a protocol in your detailview and implement it in your rootview.Pass the selected string as parameter to delegate method and from the delegate method, display it in your textfield.

    //something like this
    @interface detailViewController
    
    // protocol declaration 
    @protocol myDelegate
    @optional
       -(void)selectedValueIs:(NSString *)value;
    
    // set it as the property
    @property (nonatomic, assign) id selectedValueDelegate;
    
    // in your implementation class synthesize it and call the delegate method
    @implementation detailViewController
    @synthesize selectedValueDelegate
    // in your didselectRowAtIndex method call this delegate method
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
     {
    
          [self  selectedValueDelegate])selectedValueIs:valueString] ;
          [self.navigationController popViewControllerAnimated:YES];
    
      }
    
    
    
    
    @end
    
    // In your rootViewController conform to this protocol and then set the delegate
    
             detailViewCtrlObj.selectedValueDelegate=self;
    //Implement  the delegate Method 
         -(void)selectedValueIs:(NSString *)value{
           {
                // do whatever you want with the value string
           }
    

提交回复
热议问题