我创建了一个看起来像这个图像的按钮。
在每个按钮上我设置了不同的视图。并使用此代码进行更改视图... 下面的代码是关于视图的
- (void)segmentedControlChangedValue:(SVSegmentedControl*)segmentedControl {
NSLog(@"segmentedControl %i did select index %i (via UIControl method)", segmentedControl.tag, segmentedControl.selectedIndex);
switch (segmentedControl.selectedIndex)
{
case 0:
{
[super viewDidLoad];
break;
}
case 1:{
tr=[[[Table_review alloc]initWithNibName:@"Table_review" bundle:nil]autorelease];
tr.dv=self;
tr.business_obj=business;
[self.navigationController pushViewController:pv_Object animated:NO];
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
}
break;
case 2:
{
pv_Object=[[[Photo_View alloc]initWithNibName:@"Photo_View" bundle:nil]autorelease];
pv_Object.dv=self;
pv_Object.business_obj=business;
[self.navigationController pushViewController:pv_Object animated:NO];
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
}
break;
}
}
以下代码用于审核视图
- (void)segmentedControlChangedValue:(SVSegmentedControl*)segmentedControl {
NSLog(@"segmentedControl %i did select index %i (via UIControl method)", segmentedControl.tag, segmentedControl.selectedIndex);
switch (segmentedControl.selectedIndex)
{
case 0:
{
[self.navigationController popViewControllerAnimated:FALSE];
break;
}
case 1:
[super viewDidLoad];
break;
case 2:
{
pv_Object=[[[Photo_View alloc]initWithNibName:@"Photo_View" bundle:nil]autorelease];
pv_Object.tr_Object=self;
pv_Object.business_obj=business_obj;
[self.navigationController pushViewController:pv_Object animated:NO];
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
}
break;
}
}
以下代码用于照片视图
- (void)segmentedControlChangedValue:(SVSegmentedControl*)segmentedControl {
NSLog(@"segmentedControl %i did select index %i (via UIControl method)", segmentedControl.tag, segmentedControl.selectedIndex);
switch (segmentedControl.selectedIndex)
{
case 0:
{
[self.navigationController popViewControllerAnimated:YES];
break;
}
case 1:{
[self.navigationController popViewControllerAnimated:YES];
}
break;
case 2:
{
[super viewDidLoad];
}
break;
}
}
现在的问题是,当试图审查和审查照片和照片时。然后它杀了程序。 那么我在第三个代码中改变了什么以便它能正常工作?
提前致谢..
答案 0 :(得分:0)
代码的第一部分替换:
[self.navigationController pushViewController:pv_Object animated:NO];
用这个
[self.navigationController pushViewController:tr animated:NO];