2014-07-26 1 views
0

나는 SO를 검색했고 웹은 에이미 답을 찾지 못했습니다.
스토리 보드 메인 UITableViewController에서 A라는 간단한 버튼이 생성되었습니다. 및 webView 및 닫기 버튼이있는 B라는 다른 ViewController.
주 UITableViewController 어떤 형태로든 연결되어 있지 않습니다.
이제 B viewController 폼을 열고 그 다음 자신의 닫기 단추로 B ViewController를 닫고 싶습니다.
하지만 B 뷰 컨트롤러는 검정색과 검정색으로되어 있습니다.presentView 스토리 보드가있는 컨트롤러가 검은 색으로 보임 iOS 7.1 xcode 5.1

의 ViewController B (나는 B를 열려고되는 메인 뷰 컨트롤러) (팝업 뷰)

#import "TAFBLoginDialogViewController.h" 

@interface TAFBLoginDialogViewController() 

@end 

@implementation TAFBLoginDialogViewController 

-(id)initWithAppId:(NSString *)apiKey 
    requestPremision:(NSString *)requestPremision 
      delegate:(id<TAFBLoginDialogViewdelegate>)delegate 
      storyBoardName:(NSString*) storyBoardName 
{ 
    //self = [super initWithNibName:@"FBLoginDialog" bundle:nil]; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyBoardName bundle:nil]; 

    UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"FBLoginDialog"]; 
    if (self) { 
     // Custom initialization 
     self.apiKey = apiKey; 
     self.requestPremision = requestPremision; 
     self.delegate = delegate; 
    } 
    return self; 
} 



- (IBAction)closeTap:(id)sender 
{ 
    [self.delegate closeTaped]; 
} 


-(void)login 
{ 

} 
-(void)logout 
{ 


} 
-(void)checkForAccessToken:(NSString*)urlString 
{ 

} 
-(void)checkLoginRequired:(NSString*)urlString 
{ 
    [self.delegate displayRequired]; 
} 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

있는 UITableViewController

#import "TAFMETableViewController.h" 


@interface TAFMETableViewController() 
{ 
} 
@end 

@implementation TAFMETableViewController 

- (id)initWithStyle:(UITableViewStyle)style 
{ 
    self = [super initWithStyle:style]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 
-(void) awakeFromNib 
{ 


    [super awakeFromNib]; 
} 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
#warning Potentially incomplete method implementation. 
    // Return the number of sections. 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
#warning Incomplete method implementation. 

} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    return cell; 
} 


- (IBAction)handleOpenFBDialog:(id)sender { 
    UIStoryboard * storyboard = self.storyboard; 
    NSString * storyboardName = [storyboard valueForKey:@"name"]; 

    self.appId = @"11111"; 
    self.permissions [email protected]"public_stream"; 

    if(_loginDialogView ==nil) 
    { 
     self.LoginDialogViewController = [[TAFBLoginDialogViewController alloc] initWithAppId:_appId 
                   requestPremision:_permissions 
                   delegate:self storyBoardName:storyboardName]; 
     self.loginDialogView = _LoginDialogViewController.view; 
    } 

    [self.LoginDialogViewController checkLoginRequired:@"tst"]; 

    NSLog(@"Click!"); 
} 


-(void)accessTokenFound:(NSString*)accessToken 
{ 
    NSLog(@"accessTokenFound Click!"); 
} 
-(void)displayRequired 
{ 
    NSLog(@"displayRequired Click!"); 
    [self presentViewController:_LoginDialogViewController animated:YES completion:nil]; 
} 
-(void)closeTaped 
{ 
    NSLog(@"closeTaped Click!"); 
    [self dismissViewControllerAnimated:NO completion:nil]; 
} 


@end 

헤더 파일 :

@protocol TAFBLoginDialogViewdelegate 

-(void)accessTokenFound:(NSString*)accessToken; 
-(void)displayRequired; 
-(void)closeTaped; 

@end 


@interface TAFBLoginDialogViewController : UIViewController<UIWebViewDelegate> 
{ 
    //ivars 
// UIWebView *_webview; 
// NSString* _apiKey; 
// NSString* _requestPremision; 
// id <TAFBLoginDialogViewdelegate> _delegate; 
} 

@property (retain) IBOutlet UIWebView *webView; 
@property (copy) NSString *apiKey; 
@property (copy) NSString *requestPremision; 
@property (assign) id<TAFBLoginDialogViewdelegate> delegate; 

-(id)initWithAppId:(NSString*)apiKey 
      requestPremision:(NSString*)requestPremision 
      delegate:(id<TAFBLoginDialogViewdelegate>)delegate 
      storyBoardName:(NSString*) storyBoardName; 

- (IBAction)closeTap:(id)sender; 
-(void)login; 
-(void)logout; 
-(void)checkForAccessToken:(NSString*)urlString; 
-(void)checkLoginRequired:(NSString*)urlString; 


@end 

나는 그 방아쇠를 TableView A에 넣습니다 :

,210
- (IBAction)handleOpenFBDialog:(id)sender 

는 이것을의 ViewController B 및 호출 초기화 기능 :의 ViewController B 을 보여 가정

[self.LoginDialogViewController checkLoginRequired:@"tst"]; 

하지만 모두가 않습니다 검은 화면을 보여줍니다.

답변

1

initWithAppID 메소드에서 스토리 컨트롤러에서 뷰 컨트롤러를 인스턴스화 한 다음 아무 것도하지 않습니다. 그렇다면 if (self) 초기화 블록이 있지만 자신을 초기화 한 적이 없습니다.

스토리 보드에서 인스턴스화 한보기 컨트롤러와 동일하게 설정 한 다음 속성을 설정하는 것처럼 보입니다.

대신보기 컨트롤러 객체를 할당하고 init 메소드에서 스토리 보드의 다른 객체를 만들고 할당 한 객체를 무시한 후에이 객체를 클래스 메소드로 만드는 것이 더 합리적 일 수 있습니다. 내가 바로 apiKey에 다른 모든 속성을 설정하지 않은 추측 이러한 오류를 받고 응답 메신저에 대한

+(instancetype) TAFBLoginDialogViewControllerWithAppID:(NSString *)apiKey 
    requestPremision:(NSString *)requestPremision 
      delegate:(id<TAFBLoginDialogViewdelegate>)delegate 
      storyBoardName:(NSString*) storyBoardName 
{ 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyBoardName bundle:nil]; 

    TAFBLoginDialogViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"FBLoginDialog"]; 

    // Custom initialization 
    viewController.apiKey = apiKey; 
    viewController.requestPremision = requestPremision; 
    viewController.delegate = delegate; 

    return viewController; 
} 
+0

감사 : '의 UIViewController *' 재산권 'requestPremision'유형의 개체에없는 속성 'apiKey에' 'UIViewController *'유형의 객체에서 찾을 수 없습니다. 질문을 업데이트했습니다. – user63898

+0

죄송합니다. 예제에서는 viewController를 TAFBLoginDialogViewController가 아닌 UIViewController로 선언 했으므로 속성이 존재하지 않는다는 오류가 발생합니다. 예를 업데이트했습니다. – Brandon

+0

당신은 남자입니다! 감사! – user63898

관련 문제