UIPopoverController 与 UITableView

发布于 2024-11-18 05:04:08 字数 1084 浏览 8 评论 0原文

我有一个 UIPopoverController,其中有一个已填充的 UITableView。我试图将信息从 popovercontroller 传递到超级视图。放置在 popovercontroller 中的 tableview 正在使用 didSelectRow 方法接收信息,但该信息不会传输到放置在 superView 中的 textView。

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

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

谢谢

    - (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;
     }


    }

在我的 SuperView 中

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

I have a UIPopoverController that has a UITableView that is populated. I am trying to pass the information from the popovercontroller to the superview. The tableview that is placed in the popovercontroller is receiving the information with the didSelectRow method but the information is not transferring to the textView placed in the superView.

Below is the code I use to try and place the selected user in the textview and underneath that is the Superview code where I try to take the string and place it into the actual field when the index is clicked. I know my issue is I am not telling my superView that the row was touched and to send that information into the field but I have searched and con not find a good explanation on how to attempt this.

If anyone has any suggestions that would be great!

thanks

    - (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;
     }


    }

In my SuperView

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

客…行舟 2024-11-25 05:04:08

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

https://developer.apple.com/库/内容/文档/常规/概念/DevPedia-CocoaCore/Delegation.html

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

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

In order to pass information from the View Controller of the popover you're going to want to set up a delegate. Here's a link to Apple's documentation and also a good guide example.

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

Essentially when you create the View Controller that houses the methods for your table view, you'll want to give it a delegate. Then once a cell is selected in your table view, you'll be able to send a call to your delegate with any information you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文