嗨,这是我的第一个 iPad 应用程序,并试图将我的 iphone 应用程序移植到 iPad。我已按照http://www.raywenderlich.com/的所有教程进行操作,但仍有问题。
还要查看这个问题,但仍然有问题。Splitviewcontroller 有两个表视图,委托问题
基本上,我在 SplitViewController 中有两个 UITableViewController,当我单击根视图控制器中的 tableview 单元格时,我想在另一个 Tableview 右侧的 DetailsViewController 中填充详细信息。
问题是我可以设法从中传递数组数据,但我不能调用 tableview reload 方法。
这是代码
左视图控制器
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
if (row == 0){
NSLog(@"Row 0 Pressed");
RightViewController *rightvc = [self.storyboard instantiateViewControllerWithIdentifier:@"displayenglish"];
_locallayleft = [ConversationDatabase database].conversationsInfos;
NSLog(@"Just pushed the array");
rightvc.detailItem = _locallayleft;
rightvc.title = @"Greetings";
}
else if (row == 1) {
NSLog(@"Row 1 Pressed");
RightViewController *rightvc = [self.storyboard instantiateViewControllerWithIdentifier:@"displayenglish"];
_locallayleft = [ConversationDatabase database].conversationsInfosgeneral;
rightvc.detailItem = _locallayleft;
rightvc.title = @"General Conversation";
}
-----------------------------------------------------------------------------------------
RightViewController
- (void)setDetailItem:(NSArray *)newDetailItem
{
if(_detailItem != newDetailItem) {
_detailItem = newDetailItem;
[self configureView];
}
}
- (void)configureView
{
if (self.detailItem) {
self.locallay = self.detailItem;
_listOfCoversation = [[NSMutableArray alloc] init];
for (ConversationInEnglish *c in _locallay)
{
NSString *english = c.english;
NSLog(@"setDetails Item get called");
NSLog(@"%@",english);
[_listOfCoversation addObject:english];
}
[self.tableView reloadData];
NSLog(@"Trying to reload TableView");
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self configureView];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_locallay count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"English";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
ConversationInEnglish *con = _locallay [indexPath.row];
_englishLabel = (UILabel *) [cell viewWithTag:200];
_englishLabel.text = con.english;
NSLog(@"My data from cell %@",con.english );
[_englishLabel setFont:[UIFont fontWithName:@"Open Sans" size:22]];
_myanmarLabel = (UILabel *) [cell viewWithTag:300];
[_myanmarLabel setFont:[UIFont fontWithName:@"TharLon" size:17]];
_tonebasedLabel = (UILabel *) [cell viewWithTag:400];
_tonebasedLabel.text = con.tone_based;
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"tableviewcell.png"]];
self.tableView.backgroundColor = background;
return cell;
}