在我的项目中,单击按钮时,按钮Action方法中的字符串应该存储在popover表视图单元格中。
我可以将单个刺痛存储到第一个细胞......
现在我的问题是我有四个按钮每个按钮动作由4个字符串组成,现在应该一次到popover表视图,,,
#import "SecondDetailViewController.h"
-(IBAction)viewButtonPressed:(id)sender
{
[super viewDidUnload];
//create the view controller from nib
self.tablePopoverController = [[[TablePopoverController alloc]
initWithNibName:@"TablePopover"
bundle:[NSBundle mainBundle]] autorelease];
////-------------------------------
myArray = [[NSMutableArray alloc] initinitWithObjects:myString,myString2,myString3,myString4,myString5,myString6,nil];
tablePopoverController.getingOrder = myArray ;
NSLog(@"table popo %@",myArray);
tablePopoverController.contentSizeForViewInPopover = CGSizeMake(250, 250);
//create a popover controller
self.popoverController = [[[UIPopoverController alloc]
initWithContentViewController:tablePopoverController] autorelease];
//present the popover view non-modal with a
//refrence to the button pressed within the current view
[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
-(IBAction)orderButtonPressed
{
myString = staterlable1.text;
[myArray addObject:myString];
NSLog(@"myArray%@",myString);
}
-(IBAction)orderButton2Pressed
{
myString2 = staterlable2.text;
NSLog(@"myArray%@",myString2);
[myArray addObject:myString2];
}
-(IBAction)orderButton3Pressed
{
myString3 = staterlable3.text;
[myArray addObject:myString3];
NSLog(@"myArray%@",myString3);
}
-(IBAction)orderButton4Pressed
{
myString4 = staterlable4.text;
[myArray addObject:myString4];
NSLog(@"myArray%@",myString4);
}
-(IBAction)orderButton5Pressed
{
myString5 = staterlable5.text;
[myArray addObject:myString5];
NSLog(@"myArray%@",myString5);
}
-(IBAction)orderButton6Pressed
{
myString6 = staterlable6.text;
[myArray addObject:myString6];
NSLog(@"myArray%@",myString6);
我的问题点击这些按钮后,myString1 - to - myString6 NSString对象应存入NSMutableArray,这样我将显示TableViewPopOverController中的所有字符串,当单击第二个detailViewController中的另一个按钮时,它将弹出...
先谢谢......
答案 0 :(得分:2)
通常的方法是在UINavigationController中嵌入TablePopoverController。然后,在TablePopoverController中处理tableView时:tableView didSelectRowAtIndexPath:indexPath将detailViewController推送到UINavigationController中。
例如,您可以通过以下方式构建Controller结构(基于您的示例):
//create a popover controller
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:[[[UINavigationController alloc] initWithRootViewController:initWithContentViewController:tablePopoverController] autorelease]] autorelease];
它类似于你的popover创建代码,put在弹出窗口下插入一个UINavigationController。现在,在TablePopoverController中,您应该使用UINavigationController以常规方式处理行选择
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DetaiViewController *detail = [[DetaiViewController alloc] init];
/* Configure detail using indexpath here indexPath
...
*/
[self.navigationController pushViewController:detail animated:YES];
}
这将按预期工作(通过将新视图推入UINavigationController),因为我们使用UINavigationController设置控制器结构。