Programing

펜촉이 장착되었지만 '보기'콘센트가 설정되지 않았습니다.

crosscheck 2020. 9. 30. 08:42
반응형

펜촉이 장착되었지만 '보기'콘센트가 설정되지 않았습니다.


프로젝트에 새 nib 파일을 추가하고로드하려고했습니다.

그러나 내가 만든보기로 이동해야하는 도구 모음 아이콘을 클릭 NSInternalInconsistencyException하면 다음 메시지가 표시됩니다.

포착되지 않은 예외 'NSInternalInconsistencyException'으로 인해 앱을 종료하는 중입니다. 이유 : '-[UIViewController _loadViewFromNibNamed : bundle :]이 "..."펜촉을로드했지만 뷰 아웃렛이 설정되지 않았습니다.'

그래서 나는 펜촉 파일을 열었고 참조하는 콘센트가 설정되어 있지 않다는 것을 확인했습니다. 그러나 "new referencing outlet"에 대한 원을 클릭하여 File 's Owner로 끌어다 놓으려고하는데 그렇게 할 수 없습니다.보기를 표시하려면 어떻게해야합니까?


너희 말이 맞지만 내가 처음 왔기 때문에 모든 단계를 파악하는 데 약간의 시간이 걸렸다. 나를 위해 일한 것은 다음과 같습니다.

  • 문제를 일으키는 XIB 파일 열기
  • 왼쪽 표시 줄에서 파일 소유자 아이콘을 클릭합니다 (상단, 노란색 테두리 상자 모양).
  • 오른쪽 사이드 바가 보이지 않으면 툴바에서 "보기"위에있는 세 번째 아이콘을 클릭하십시오. 오른쪽 사이드 바가 표시됩니다.
  • 오른쪽 사이드 바에서 신문처럼 보이는 세 번째 탭을 클릭합니다.
  • 상단의 "Custom Class"에서 Class가이 뷰에 해당하는 ViewController의 이름인지 확인합니다. 그렇지 않은 경우 입력하십시오.

커스텀 클래스 구성

  • 오른쪽 사이드 바에서 마지막 탭 (화살표가있는 원 모양)을 클릭합니다.
  • 아래에 "보기"가있는 "아울렛"이 표시되어야합니다. 그 옆에있는 원을 왼쪽 막대의 "보기"아이콘으로 드래그하십시오 (아래쪽, 두꺼운 회색 윤곽선이있는 흰색 정사각형 모양).

커스텀 클래스 구성

  • xib를 저장하고 다시 실행하십시오.

이것은 Josh Justice 제안이지만 그래픽 방식으로 (사진은 내 것입니다) :

  1. 파일 소유자 선택
  2. 오른쪽 패널에서 사용자 정의 클래스를 선택하십시오.
  3. 사용자 정의 클래스 이름을 입력하십시오.

여기에 이미지 설명 입력

  1. 오른쪽 패널에서 출력 선택
  2. 구성 요소를 보려면보기 콘센트를 드래그하십시오.

여기에 이미지 설명 입력

마지막으로 View Controller는 롤링 코드로 인스턴스화됩니다.

        PTFilterUserVC *aFilterUserVC = [[PTFilterUserVC alloc] initWithNibName:@"FilterVC" bundle:nil];

        //OPTIONAL.This is how 'I' am interested in present the view controller.
        [self.navigationController pushViewController:aFilterUserVC animated:YES];

일반적으로 파일의 소유자와보기 간의 연결을 다시 만들어 문제를 해결할 수 있습니다. 파일 소유자에서보기 (IB)로 Control- 드래그하고 팝업 메뉴에서보기를 선택합니다.


보기 ID-클래스 ID가 설정되지 않았습니다. 적절한 클래스로 설정 한 후 문제가 해결되었습니다.


yourViewController의 "view"속성에 할당 된 UIView (또는 하위 클래스)가 확실합니까?

yourViewController에 대한 xib의 왼쪽 창에서 "파일 소유자"를 마우스 오른쪽 버튼으로 클릭하고 "보기"출력이 설정되었는지 확인합니다. 그렇지 않은 경우보기로 설정하십시오!

이것은 확실히 문제를 해결합니다


XCode 4.6.3에서 동일한 문제가 발생했습니다. 나는라는 이름의 두 파일을 시작했다 MySettingsView.h.m하지만 찬성을 삭제 MySettingsViewController.h,하지만 힌트의 대부분이 여기에 언급 시도해도에도 불구하고, 그것은 여전히으로 erroring 유지

2013-07-05 11 : 48 : 17.205 MyApp [39024 : c07] *** 포착되지 않은 예외 'NSInternalInconsistencyException'으로 인해 앱 종료, 이유 : '-[UIViewController _loadViewFromNibNamed : bundle :]이 "MySettingsView"펜촉을로드했지만보기 아울렛 설정되지 않았습니다. '

MySettingsView Controller .xib 대신 MySettingsView.xib를로드하려고 시도하면서 여전히 "혼란 스러웠습니다" . 아마도 그것의 "내 말대로하기"논리가 너무 화려할 수도 있습니다.

그래서 MySettingsViewController.m에서 NIB / XIB 이름을 하드 코딩하여 문제를 해결했습니다.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:@"MySettingsViewController" bundle:nibBundleOrNil];
}

나를 위해 여기에 언급 된 모든 것 https://stackoverflow.com/a/6395750/939501 이 사실이지만 여전히 오류가 발생했습니다. 이유는 ABCView라는 이름의 View 클래스를 만든 다음 나중에 삭제했기 때문에 뷰 컨트롤러를 다음과 같이 추가했습니다. ABCViewController 그래서 어떻게 든 새 뷰 컨트롤러에서 이전 ABCView를 참조하고 있었기 때문에 ABCViewController를 삭제하고 내 문제를 해결하는 다른 이름으로 새로운 것을 추가해야했습니다.

감사


xib 메서드를 사용하여 UIView를 생성하고이 문제가있는 사람에게는 연결 검사기 메뉴 아래에 "보기"출력이 없다는 것을 알 수 있습니다. 그러나 File 's Owners 사용자 정의 클래스를 UIViewController로 설정하면 "view"출력이 표시됩니다. CMND는 출력을 CustomView에 연결할 수 있습니다.


이것에 대한 내 문제는 뷰 세트가없는 클래스 폴더에 중복 펜촉이 있기 때문에 발생했습니다. xcode는 빌드를 위해 하나의 펜촉을 선택하고 다음에 프로젝트를 빌드 할 때 다른 하나를 선택하는 것처럼 보였습니다. 다른 하나를 삭제했습니다. 좋아 보인다. 도!


nib에서 시작할 때 내 뷰 속성이 뷰 컨트롤러에 설정되지 않은 이유를 찾으려고 한 시간 이상을 보냈습니다. 뷰 컨트롤러의 initWithNibName 내에서 "[super initWithNibName ...]"을 호출하는 것을 잊지 마십시오.


내 문제를 해결했습니다. 큰 프로젝트, 두 개의 파일. 하나는 "ReallyLargeNameView"이고 다른 하나는 "ReallyLargeNameViewController"였습니다.

위에서 선택한 두 번째 답변에 따라 빌드를 정리해야한다고 결정했습니다. Nada, 그러나 나는 여전히 XCode를 의심했습니다. (내가 두 개의 동일한 클래스를 가지고 있기 때문에 그것들을 추상화해야하지만 어 ...) 그래서 하나는 작동하고 하나는 그렇지 않습니다. 파일의 소유자 이름은 복사 및 붙여 넣기, 콘센트 다시 연결, xCode 재부팅, 여전히 아무것도 없습니다.

그래서 비슷한 이름의 클래스 (뷰)를 삭제합니다. 곧 새로운 오류 "outlet inside not hooked up"은 문자 그대로 "webView not key value"였는데 ... 기본적으로 "Visual Studio가 더 낫다"라고 말합니다. 어쨌든 ... 더 작은 이름의 파일을 지우면 작동합니다.

XCode는 비슷한 이름의 파일과 혼동됩니다. 그리고 프로젝트는 재부팅이 필요할만큼 충분히 큽니다.

"XCode is confused"보다 더 기술적 인 답변이 있었으면 좋겠지 만, xCode는이 시점에서 많이 혼란스러워집니다. 내가 어린 아이를 도울 때와 같은 방식으로 혼란스러워하지 않았습니다. 지금 작동합니다. :) 위의 내용이 아무것도 고치지 않으면 다른 사람들에게 도움이 될 것입니다.

항상 빌드를 정리하는 것을 잊지 마십시오 (시뮬레이터도 삭제하여).


나는 또한 같은 문제가 있었고 내 문제는 다른 현지화 (영어)를 ViewControllers nib에 추가하여 현지화 독일어가있는 내 앱이 현지화 영어로 펜촉을 찾을 수 없다는 것입니다! 이것이 누구에게나 도움이되기를 바랍니다!


실수로 xib 참조를 삭제하고 다시 추가하는 동안 동일한 문제가 발생했습니다. 방금 파일 소유자와 뷰를 연결하여 수정했습니다. 또한 FilesOwner의 사용자 정의 클래스가 예상되는 viewController인지 확인하십시오.


나에게 문제는 initWithNibName:bundle:. 펜촉 파일의 테이블 뷰 셀을 사용하여 tableViews. 나는 전망이 없기 때문에 하나에 연결하는 것이 의미가 없습니다. 대신 initWithStyle:메서드를 호출하고 거기에서 nib 파일을로드하면 예상대로 작동합니다.


나는 같은 문제가 있었지만 약간 다른 해결책이 필요했습니다. 이 경우 문제는보기의 클래스가 아니라 파일 소유자의 클래스였습니다. 이를 설정하기 위해 Interface Builder 창의 왼쪽 하단에있는 "backwards play"아이콘을 클릭해야했습니다. 그러면 파일 소유자, 첫 번째 응답자 및보기의 특성을 분리하는 옵션이 나타납니다. 첫 번째 (큰 투명 상자)를 클릭하면 위에서 제안한대로 사용자 정의 클래스를 설정할 수 있습니다.


나는 같은 문제가 있었지만 다른 해결책이 필요했습니다. 이 경우 문제는 파일 소유자의 클래스가 xib 파일에 연결되지 않았다는 것입니다.


오늘 밤 Swift UIViewController 하위 클래스를 사용하여 매우 유사한 것을 만났습니다. 이 경우 위의 수정 사항 중 어느 것도 작동하지 않았지만 코드 순서를 약간 변경하면 효과가 있습니다. Net-net, 하위 클래스에 대한 확장이있는 경우 동일한 파일에서 하위 클래스의 정의 자체가 제대로 컴파일 되었음에도 불구하고 XCode를 혼동하는 것처럼 보입니다. 수정 사항은 하위 클래스의 정의 뒤에 확장을 배치하는 것입니다.

이 유사한 질문에 대한 답변에 세부 정보 게시했습니다 .


제 경우에는 - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil*** ViewController 클래스에 지정된 이니셜 라이저 가 구현되어 있으므로 다른 이니셜 라이저를 호출하여 객체를 초기화하더라도 지정된 이니셜 라이저가 호출됩니다.

따라서이 문제를 해결하는 - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil것도 올바른 방법입니다.


이전 답변 은 거의 문제를 해결했지만 마지막 단계가 누락되었습니다.

  1. 동일한 이름으로 xib 및 swift 파일을 만듭니다.

보기 및 Swift 파일 추가

  1. 파일 소유자를 UIView 서브 클래스로 설정하십시오.

여기에 이미지 설명 입력

  1. View에서 UIView 하위 클래스로 콘센트를 드래그하고 이름을 "contentView"로 지정합니다.

contentview 추가

  1. xib가로드 될 때 contentView를 첨부하도록이 사용자 정의 이니셜 라이저를 추가하십시오.

contentview를 하위보기로 추가

required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        Bundle(for: self.classForCoder).loadNibNamed("SampleView", owner: self, options: nil)
        addSubview(contentView)
        contentView.frame = self.bounds
        contentView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
    }

이제 추가하는 모든 @IBOutlets가 첨부됩니다.

건배, Richard


Just had the same error in my project, but different reason. In my case I had an IBOutlet setup with the name "View" in my custom UITableViewController class. I knew "view" was special because that is a member of the base class, but I didn't think View (different case) would also be a problem. I guess some areas of Cocoa are not case-sensitive, and probably loading a xib is one of those areas. So I just renamed it to DefaultView and all is good now.


select the files owner and goto open the identity inspecter give the class name to which it corresponds to. If none of the above methods works and still you can't see the view outlet then give new referencing outlet Connection to the File's Owner then you can able to see the view outlet. Click on the view Outlet to make a connection between the View Outlet and File's owner. Run the Application this works fine.


In my case, the view was not viewed in xib. in xib the View was size = none (4th tab right hand). I set size to Freeform and reload xCode. view was appealed and I set the proper link to View.


If you have tried everything and you still get this error, try re-creating the class file from scratch but remember to select the "Also create XIB file" check box. This will auto link up a few items that are not linked when creating these files separately. After this is created, you can likely cut and paste everything onto the new XIB and it should work fine.

I am finding this issue specifically with creating files separately in Swift.


for me it happened, when

  • I have a ViewController class ( .mm/h ) associated with the Nib file,
  • UIView from this ViewController has to be loaded on the another view as a subview,

  • we will call something like this

    -(void)initCheckView{
    
       CheckView *pCheckViewCtrl = [CheckView instance];
    
       pCheckView = [pCheckViewCtrl view];
    
       [[self view]addSubview:pCheckView];
    
       [pCheckViewCtrl performCheck];        
    
    }
    

Where

+(CheckView *)instance{
    static CheckView *pCheckView = nil;
    static dispatch_once_t checkToken;

    dispatch_once(&checkToken, ^{
        pCheckView = [[CheckView alloc]initWithNibName:@"CheckView" bundle:nil];
        if ( pCheckView){
            [pCheckView initLocal];
            **[pCheckView loadView];**
        }
    });

    return pCheckView;

}

Here loadView was missing,,, adding this line resolved my problem.


I had the same problem, I figured out and it is because of i had ticked "Static cells" in the properties of Table View under Content option. Worked when it changed to "Dynamic Prototypes". Screenshot is below. 여기에 이미지 설명 입력


I had a similar problem with Xcode 9.3, and setting "Module" under the "File Owner's" attribute inspector to the project module fixed this for me.


Open your storyboard file where your viewController exists, or XIB related file with textEdit.app and check if the storyboard or XIB name is the same of your viewController, then change it, save and reload/restart Xcode.


I'd like to second Stephen J. Some times X Code does just get confused. I just had an experience where I had played around with the UI a lot, and had added and deleted outlets quite a few times. The outlets just would not wire-up any more. I never did figure out a specific reason (I had tried all the solutions above), and I just had to delete the NIB and recreate it from scratch, and in fact had to use a different name for the NIB before it would work. (XCode 4.6.1) Wasted a couple of hours on that.


When you have a Swift code that references different namespace with @objc, be sure to use the Objective-C class name:

@objc(NamespacedSomeViewController)
class SomeViewController: UIViewController {
....

In this case, you need to use NamespacedSomeViewController in the IB.


If you're using a custom init method, check that you're returning something valid. I ran into a piece of code that crashed on something like this:

- (id)init {
   self = [super init];
   if (self) {
      CustomController *controller = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(className) owner:self options:nil];
   } return self;
}

다른 클래스에서 컨트롤러는 다음과 같이 생성되었습니다.

CustomController *controller = [[CustomController alloc] init];

문제는 init 메서드에서 self가 변경되지 않았으며 대신 다음과 같이 표시되어야한다는 것입니다.

- (id)init {
   self = [super init];
   if (self) {
      CustomController *controller = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(className) owner:self options:nil];
      [controller viewDidLoad];
      self = controller;
   } return self;
}

참고 URL : https://stackoverflow.com/questions/4763519/loaded-nib-but-the-view-outlet-was-not-set

반응형