-1
嘿,大家好我試圖離開增強現實並轉到下一個視圖控制器到我的導航控制器UINavigation控制器的UIViewController和UItoolbar作爲一個子視圖的問題
的代碼是從ARKit演示,我只是增加了編程方式UIToolbar作爲具有操作按鈕..我一個子視圖想這個按鈕導致我現有的導航控制器的下一個視圖控制器。動作takePicture:被執行,因爲我有一個的NSLog消息,但新的ViewController未添加
這是的ARGeoViewController.h
#import <Foundation/Foundation.h>
#import "ARViewController.h"
#import "AfterARViewController.h"
@interface ARGeoViewController : ARViewController {
CLLocation *centerLocation;
AfterARViewController *afterARViewController;
}
@property (nonatomic, retain) CLLocation *centerLocation;
- (IBAction)takePicture:(id)sender;
@property (nonatomic, retain) AfterARViewController *afterARViewController;
@end
這個代碼是ARGeoViewController.m
的代碼#import "ARGeoViewController.h"
#import "ARGeoCoordinate.h"
#import "ARViewController.h"
@implementation ARGeoViewController
@synthesize centerLocation;
@synthesize afterARViewController;
- (void)setCenterLocation:(CLLocation *)newLocation {
[centerLocation release];
centerLocation = [newLocation retain];
for (ARGeoCoordinate *geoLocation in self.coordinates) {
if ([geoLocation isKindOfClass:[ARGeoCoordinate class]]) {
[geoLocation calibrateUsingOrigin:centerLocation];
if (geoLocation.radialDistance > self.maximumScaleDistance) {
self.maximumScaleDistance = geoLocation.radialDistance;
}
}
}
}
-(void)viewWillAppear:(BOOL)animated{
UIToolbar *toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleBlackTranslucent;
// create a bordered style button with custom title
UIBarButtonItem *playItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera
target:self
action:@selector(takePicture:)] autorelease];
NSArray *items = [NSArray arrayWithObjects:
playItem,
nil];
toolbar.items = items;
// size up the toolbar and set its frame
// please not that it will work only for views without Navigation toolbars.
[toolbar sizeToFit];
CGFloat toolbarHeight = [toolbar frame].size.height;
CGRect mainViewBounds = self.view.bounds;
[toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds),
CGRectGetMinY(mainViewBounds) + CGRectGetHeight(mainViewBounds) - (toolbarHeight),
CGRectGetWidth(mainViewBounds),
toolbarHeight)];
[self.view addSubview:toolbar];
}
- (IBAction)takePicture:(id)sender
{
NSLog(@"takepicture");
if(self.afterARViewController == nil)
{
AfterARViewController *afterARController = [[AfterARViewController alloc]
initWithNibName:@"AfterARViewController" bundle:[NSBundle mainBundle]];
self.afterARViewController = afterARController;
[afterARController release];
[cameraController release];
}
[self.navigationController pushViewController:self.afterARViewController animated:YES];
}
@end
謝謝你這麼多