을 선택할 때 충돌 :jQuery과 내가 내의 tableview에서 셀에, 응용 프로그램 충돌을 클릭하면 행
// QuestionViewController.h
@interface QuestionViewController : UIViewController <UITableViewDelegate , UITableViewDataSource> {
}
@property (nonatomic, strong) AppDelegate *app;
@property (nonatomic, retain) PFObject *feed;
@end
// QuestionViewController.m
@synthesize app, feed;
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
return [[feed objectForKey:@"options"] count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSString *cellTxt = [[[feed objectForKey:@"options"] objectAtIndex:indexPath.row] objectForKey:@"option_text"];
[[cell textLabel] setText:cellTxt];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"clicked cell");
}
- (void)viewDidLoad {
[super viewDidLoad];
app = [[UIApplication sharedApplication]delegate];
feed = [app.feed objectAtIndex:0];
}
것은 내가 didSelectRowAtIndexPath을 구현하지만,이 충돌 전에 호출되지 않습니다.
SO의 다른 스레드는 연결되지 않은 콘센트를 제안하지만 이것이 사실이 아니라고 확인했습니다.
for (int a = 0; a < totalQuestions; a++) {
QuestionViewController *temp = (QuestionViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"aQuestion"];
temp.view.frame = CGRectMake(self.view.frame.size.width*a+scrollWidthBeforeAppend, 0, 320, 443);
[scroller addSubview:temp.view];
}
을 그리고 스크롤 뷰에 추가 :
I는 다음과 같이 위의 UIViewController의 여러 인스턴스를 만드는 오전. 그들은 올바르게 표시하고, UITableView가 채워지며, 셀을 클릭 할 때가 아닌 다른 모든 것이 제대로 작동하는 것처럼 보입니다. 어떤 제안?
사용자 정의 컨테이너보기 컨트롤러 API를 사용하여보기 컨트롤러를 추가하려는 컨트롤러의 하위 항목으로 추가하지 않고 한 컨트롤러의보기를 다른 컨트롤러의보기에 추가하지 마십시오. – rdelmar
@rdelmar 나쁜 생각/나쁜 디자인보기 컨트롤러 (아래 답변) 배열을 maintaing인가요? – StuR
일반적으로 나쁜 생각은 아니지만 즉각적인 문제를 해결하지만 내 의견에 말했듯이 다른 컨트롤러의 뷰를 자식으로 만들지 않고 추가하는 것은 좋지 않습니다. 그렇게하면 부모 컨트롤러는 자식 포인터에 강력한 포인터 (childViewController 배열에 있음)를 유지하므로 사용자가 직접 컨트롤러 배열을 만들 필요가 없습니다. – rdelmar