2011-08-26 2 views
-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 

당신에게 내가 ARKit 경험이 아니에요

답변

0

너무 감사하지만, cameraController 탐색 컨트롤러의 스택의 일부입니다? 당신이 할 때 그것을 풀어 주면 사물을 던질 수도 있습니다. 테스트와 마찬가지로, cameraController를 릴리스하는 코드 라인을 주석 처리하여 이것이 영향을 미치는지 확인하십시오.

또한 FWIW 나는 viewDidLoad가 아니라 viewDidAppear에있는 도구 모음을 설정하는 코드를 사용해야합니다.

관련 문제