UIPopoverController 与 UITableView
我有一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了从弹出窗口的视图控制器传递信息,您需要设置一个委托。这是 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.