找到了......请问团队是否是解决方案......只是希望它是最有效率的!这是代表团的代码。
首先,落实parentViewcontroller的委托和它的方法,也请务必代表团添加到parentviewcontroller ...
@protocol SendFeedBackDelegate
- (void) didReceiveType:(NSString *) message;
@end
@interface SendFeedBackViewController : UIViewController <SKPSMTPMessageDelegate, UITableViewDataSource,UITableViewDelegate, SendFeedBackDelegate>
{
NSString *subject;
}
接下来,实施方法:- (void) didReceiveType:(NSString *) message;
下
@implementation SendFeedBackViewController
- (void) didReceiveType:(NSString *) message
{
subject = message;
[feedbackTableView reloadData];
// I reload the data because it is needed when this function is going to be called
// in the child viewcontroller.... just keep reading :)
}
现在去- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
用于这个例子和我的项目:)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [feedbackTableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// THIS IS THE IMPORTANT PIECE OF CODE YOU NEED TO NOTICE.....
// it allows for the first thing the tableview cell to be is a static string until subject
// it is changed and the user chooses a subject in the childviewcontroller
if (subject == nil) {
cell.textLabel.text = @"Select a Product";
} else {
cell.textLabel.text = subject;
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
现在,加上协议的childviewcontroller允许childviewcontroller以符合parentviewcontroller
在childviewcontroller.h:添加几行代码,
#import "ParentViewController.h"
@protocol SendFeedBackDelegate;
@interface FeedbackTypes : UITableViewController
{
id<SendFeedBackDelegate> delegate;
}
@property (nonatomic, assign) id<SendFeedBackDelegate> delegate;
现在你已经设置委托在父视图 - 控制....接下来头在同一文件执行文件(.M),并添加这些:
//Add synthesize just under @implementation "ClassName"
@synthesize delegate;
// I used a uitableviewcontroller for this example so refer to the problem I have above
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//NSLog(@"Cell's text: %@",cell.textLabel.text);
[delegate didReceiveType:cell.textLabel.text];
[self.navigationController popViewControllerAnimated:YES];
}
而这就是IT !!!! ...... :),希望这是一个简单的和基本教程,这里有一个简单的例子射击。