0

我有一个 UIPopoverController,它有一个填充的 UITableView。我正在尝试将信息从 popovercontroller 传递到 superview。放置在 popovercontroller 中的 tableview 正在使用 didSelectRow 方法接收信息,但信息没有传输到放置在 superView 中的 textView。

下面是我用来尝试将所选用户放置在 textview 中的代码,下面是 Superview 代码,我在单击索引时尝试获取字符串并将其放入实际字段中。我知道我的问题是我没有告诉我的 superView 该行已被触摸并将该信息发送到该字段,但我已经搜索并没有找到有关如何尝试此操作的良好解释。

如果有人有任何建议,那就太好了!

谢谢

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

    if (indexPath){


     NSString *selectedUser = [(Tweet*)[Friend objectAtIndex:indexPath.row] 
    followingScreenName]; 


    TwitterFollowersTimline *textBox = [[TwitterFollowersTimline alloc]   
    initWithNibName:@"TwitterFollowersTimeline" bundle:[NSBundle mainBundle]];



     textBox.selectedFriend = selectedUser;


     NSLog(@"%@", selectedUser);



     [textBox release];
     textBox = nil;
     }


    }

在我的超级视图中

    selectedFriend = [[NSString alloc] init];
    creatTweetText.text = [NSString stringWithFormat:@"@%@", selectedFriend];
4

1 回答 1

2

为了从弹出窗口的视图控制器传递信息,您需要设置一个委托。这是 Apple 文档的链接,也是一个很好的指南示例。

https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html

http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html

本质上,当您创建包含表格视图方法的视图控制器时,您需要给它一个委托。然后,一旦在表格视图中选择了一个单元格,您就可以使用您需要的任何信息向您的代表发送呼叫。

于 2011-07-04T23:40:31.727 回答