뷰 하단의 탭 막대 버튼을 클릭하면 MainViewController의 중앙 뷰에 segue를 통해 dataViewController라는 다른 뷰 컨트롤러가 채워지는 MainViewController가 있습니다. dataViewController에는 배열에서 채울 UITableView가 있습니다. 나는 내가 dataViewcontroller 초기 장면 뷰 컨트롤러를 줄 때 잘 동작하고 테이블과 모든 셀/내용을 롤오버 할 수 있기 때문에 간단한 무언가를 놓치고있다. MainViewController 초기 장면 뷰 컨트롤러를 만들 자마자 데이터 버튼을 클릭하면 뷰가 변경되어 테이블 뷰가 채워집니다. 개별 셀을 선택할 수는 있지만 강조 표시가되지만 표를 굴러 볼 때 시뮬레이터가 충돌하고 이유가 무엇인지 보여줍니다.메인 뷰 컨트롤러의 서브 뷰
MainViewController.h
#import <UIKit/UIKit.h>
@interface MainViewController : UIViewController
@property (weak,nonatomic)UIViewController *currentViewController;
@property (weak, nonatomic) IBOutlet UIView *mainView;
@end
MainViewController.m
#import "MainViewController.h"
@interface MainViewController()
@end
@implementation MainViewController
@synthesize currentViewController;
@synthesize mainView;
- (void)viewDidLoad {
[super viewDidLoad];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"location"] == NULL) [defaults setObject:@"Spring Hill" forKey:@"location"];
if ([defaults objectForKey:@"temperature"] == NULL) [defaults setObject:@"Celsius" forKey:@"temperature"];
if ([defaults objectForKey:@"windSpeed"] == NULL) [defaults setObject:@"kph" forKey:@"windSpeed"];
if ([defaults objectForKey:@"wingType"] == NULL) [defaults setObject:@"Paraglider" forKey:@"wingType"];
[defaults synchronize];
}
- (void) viewWillAppear:(BOOL)animated {
[self performSegueWithIdentifier:@"graphSegue" sender:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
self.navigationItem.title = [defaults objectForKey:@"location"];
}
@end
CustomTabBarSegue.h
#import <UIKit/UIKit.h>
@interface CustomTabBarSegue : UIStoryboardSegue
@end
CustomTabBarSeque.m
#import "CustomTabBarSegue.h"
#import "MainViewController.h"
@implementation CustomTabBarSegue
- (void) perform {
MainViewController *currentView = (MainViewController *)self.sourceViewController;
UIViewController *destView = (UIViewController *) self.destinationViewController;
for(UIView *view in currentView.mainView.subviews){
[view removeFromSuperview];
}
currentView.currentViewController = destView;
[currentView.mainView addSubview:destView.view];
}
@end
스토리 보드에있는 항목인지 잘 모르겠습니다. 선택하지 않았거나 부적절한 코드가 있습니까? 감사. 이 뷰는 다음과 같이 프로토콜을 jQuery과에 부합하도록 지정해야하는 .header 파일에서
답장을 보내 주셔서 감사합니다. tableview는 델리게이트와 데이터 소스가로드되는 뷰 컨트롤러 dataViewController를 통해로드됩니다. 만약 내가 위의 MainViewController에 테이블보기를 기대할 것이라고 기본보기 컨트롤러에 추가 한 ?? dataViewController는 유일한 뷰 컨트롤러로 작동하지만 segue 충돌을 통해로드됩니다. – veggyaurus