2012-12-11 2 views
0

테이블 뷰에서 상세 뷰로 푸는 데 문제가 있습니다. 테이블 뷰 셀을 클릭하면 셀이 강조 표시되지만 상세 뷰로 푸시되지 않습니다. 이 세부 정보보기로 전환하는 데 사용하고 있습니다 :self.navigationController 및 pushViewController 문제

[self.navigationController pushViewController:detailViewController animated:YES]; 

나는 이것이 일반적인 문제이지만 어떤 점에서 해결책을 찾을 수없는 것으로 읽었습니다. 내 full .m 파일은 아래에 있습니다. 누구든지 놀라운 권고가 있다면. 고맙습니다!

#import "ViewController.h" 
#import "DetailViewController.h" 
@interface ViewController() 
@end 

@implementation ViewController 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
self.title = @"title"; 

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 

NSURL *url = [NSURL URLWithString:@"http://website.com/json.php"]; 
NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
[[NSURLConnection alloc] initWithRequest:request delegate:self]; 
// Do any additional setup after loading the view, typically from a nib. 
} 

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 

news = [NSJSONSerialization JSONObjectWithData:data options:nil error:nil]; 
[mainTableView reloadData]; 
} 

- (int)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
return 1; 
} 

- (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
return [news count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"]; 

if(cell == nil){ 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MainCell"]; 
} 

cell.textLabel.text = textForMyLabel; 
return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"Back" style: UIBarButtonItemStyleBordered target: nil action: nil]; 

[[self navigationItem] setBackBarButtonItem: newBackButton]; 

DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 
detailViewController.title = [[news objectAtIndex:indexPath.row] objectForKey:@"name"]; 
detailViewController.newsArticle = [news objectAtIndex:indexPath.row]; 
[self.navigationController pushViewController:detailViewController animated:YES]; 
} 
+1

viewController가 'UINavigationController'내에 있습니까? –

+0

@PranjalBikashDas, 나는 그렇게 생각하지 않는다. 너무 확신 할 방법이 없다. 나는 두 개의 프로젝트를 통합하려고하고 정확히 무엇을보아야할지 모릅니다. – Brandon

+0

먼저 네비게이션 컨트롤러에 rootviewcontroller를 할당해야합니다. 그런 다음 다른보기 만 밀어 넣을 수 있습니다. –

답변

0

당신은 시도 :

[self presentModalViewController: detailViewController animated:YES]; 
+0

재미있는 방법입니다. ,하지만 정상적인 디테일 뷰처럼 전환하고 싶습니다. – Brandon

0

당신은 UINavigationController가 함께 OLY 푸시을 수행 할 수있는 컨트롤러가 UINavigationController가있는 경우, 위의 코드가 작동합니다. 두 프로젝트를 통합하려고하면 RootViewController가 UINavigationController인지 여부 만 확인합니다.

+0

어디에서 확인할 수 있습니까? – Brandon

+0

RootViewController가 무엇인지 찾기 위해 앱 대리인을 볼 수 있습니까? – Brandon

+0

예 (appdelegate) –

관련 문제