Iphone 在自定义表格视图单元格按钮操作中导航到另一个Viewcontroller
我有一个TableViewCell,其中有一个按钮缩放按钮。当我单击缩放按钮时,视图将导航到PlayerViewController () 这是我的播放按钮代码Iphone 在自定义表格视图单元格按钮操作中导航到另一个Viewcontroller,iphone,uitableview,ios7,uibutton,Iphone,Uitableview,Ios7,Uibutton,我有一个TableViewCell,其中有一个按钮缩放按钮。当我单击缩放按钮时,视图将导航到PlayerViewController () 这是我的播放按钮代码 -(IBAction)downloadAction:(id)sender { BookPlayerViewController *bookPlayerViewController=[BookPlayerViewController alloc]; [self.navigationCont
-(IBAction)downloadAction:(id)sender
{
BookPlayerViewController *bookPlayerViewController=[BookPlayerViewController alloc];
[self.navigationController pushViewController:bookPlayerViewController animated:YES];
}
我怎样才能解决这个问题?。我正在使用Nib而不是故事板来实现该项目。如果您正在加载nextview的Nib,请尝试这种方式
BookPlayerViewController *vcBookPlayerViewController = [[BookPlayerViewController alloc] initWithNibName:@"BookPlayerViewController" bundle:nil];
[self.navigationController pushViewController:vcBookPlayerViewController animated:YES];
您没有初始化nib名称。您需要使用NibName初始化BookPlayerViewController才能显示它 使用IB:
BookPlayerViewController *vcBookPlayerViewController = [[BookPlayerViewController alloc]
initWithNibName:@"BookPlayerViewController" bundle:nil];
BookPlayerViewController *vcBookPlayerViewController = [storyboard
instantiateViewControllerWithIdentifier:@"BookPlayerViewController"];
使用情节提要:
BookPlayerViewController *vcBookPlayerViewController = [[BookPlayerViewController alloc]
initWithNibName:@"BookPlayerViewController" bundle:nil];
BookPlayerViewController *vcBookPlayerViewController = [storyboard
instantiateViewControllerWithIdentifier:@"BookPlayerViewController"];
你错过了nib检查一下这个代码
-(IBAction)downloadAction:(id)sender
{
BookPlayerViewController *bookPlayerViewController=[BookPlayerViewController alloc]initWithNibName:@"BookPlayerViewController" bundle:nil];;
[self.navigationController pushViewController:bookPlayerViewController animated:YES];
}
然后我将目标添加到TableViewCellForRowatinex方法的超类中
[cell.zoomButton addTarget:self action:@selector(navigateAction:) forControlEvents:UIControlEventTouchUpInside];
然后我执行导航操作的iAction,我编写了从一个ViewController导航到另一个ViewController所需的操作
-(IBAction)navigateAction:(id)sender
{
}
这样我就解决了这个问题 它不是应该是bookplayervewcontroller*bookplayervewcontroller=[bookplayervewcontroller alloc]init];我试过使用BookPlayerViewController*BookPlayerViewController=[BookPlayerViewController alloc]init],但它不起作用。您应该尝试BookPlayerViewController*vcBookPlayerViewController=[[BookPlayerViewController alloc]initWithNibName:@“BookPlayerViewController”捆绑包:nil];[self.navigationController pushViewController:vcbookplayervewcontroller动画:是];