테이블 뷰에서 상세 뷰로 푸는 데 문제가 있습니다. 테이블 뷰 셀을 클릭하면 셀이 강조 표시되지만 상세 뷰로 푸시되지 않습니다. 이 세부 정보보기로 전환하는 데 사용하고 있습니다 :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];
}
viewController가 'UINavigationController'내에 있습니까? –
@PranjalBikashDas, 나는 그렇게 생각하지 않는다. 너무 확신 할 방법이 없다. 나는 두 개의 프로젝트를 통합하려고하고 정확히 무엇을보아야할지 모릅니다. – Brandon
먼저 네비게이션 컨트롤러에 rootviewcontroller를 할당해야합니다. 그런 다음 다른보기 만 밀어 넣을 수 있습니다. –