Ios 表视图不显示详细视图

Ios 表视图不显示详细视图,ios,uitableview,uitabbarcontroller,detailview,Ios,Uitableview,Uitabbarcontroller,Detailview,我已经在我的项目中实现了,但是没有在右侧显示箭头并单击detailview,表格占据了整个视图(甚至在状态栏上),并且没有显示箭头或推送。是因为我使用了标签栏吗?我以编程方式将其放入appdelegate文件中 我的tableviewcontroller.m - (void)viewDidLoad { [super viewDidLoad]; self.tableView.delegate = self; self.tableView.dataSource = self; [self makeR

我已经在我的项目中实现了,但是没有在右侧显示箭头并单击detailview,表格占据了整个视图(甚至在状态栏上),并且没有显示箭头或推送。是因为我使用了标签栏吗?我以编程方式将其放入appdelegate文件中

我的tableviewcontroller.m

- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self makeRestuarantRequests];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

-(void)makeRestuarantRequests
{
NSURL *url = [NSURL     URLWithString:@"https://maps.googleapis.com/maps/api/place/textsearch/json?query=restuarants+in+greenwich&sensor=false&key=AIzaSyD-kWneJACswSQfMFQ7sxRPhAEZpHHgvnw"];

NSURLRequest *request = [NSURLRequest requestWithURL:url];
//AFNetworking asynchronous url request
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

operation.responseSerializer = [AFJSONResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id     responseObject) {

    self.googlePlacesArrayFromAFNetworking = [responseObject objectForKey:@"results"];

    NSLog(@"The Array: %@",self.googlePlacesArrayFromAFNetworking);

    [self.tableView reloadData];


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

    NSLog(@"Request Failed: %@, %@", error, error.userInfo);

}];

[operation start];

}



#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

// Return the number of rows in the section.
return [self.googlePlacesArrayFromAFNetworking count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";


UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if(cell == nil)
{
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}


NSDictionary *tempDictionary= [self.googlePlacesArrayFromAFNetworking objectAtIndex:indexPath.row];

cell.textLabel.text = [tempDictionary objectForKey:@"name"];

if([tempDictionary objectForKey:@"rating"] != NULL)
{
    cell.detailTextLabel.text = [NSString stringWithFormat:@"Rating: %@ of 5",[tempDictionary   objectForKey:@"rating"]];
}
else
{
    cell.detailTextLabel.text = [NSString stringWithFormat:@"Not Rated"];
}

return cell;
}


#pragma mark - Prepare For Segue

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
ViewController *detailViewController = (ViewController *)segue.destinationViewController;
detailViewController.restaurantDetail = [self.googlePlacesArrayFromAFNetworking objectAtIndex:indexPath.row];
}

@end
我的appdelegate文件(选项卡栏内容)

两件事

  • 你的didFinishLoadingWithOptions方法看起来很奇怪。添加到self.Window中的视图控制器在哪里?此行>>
    [self.windowaddsubview:viewController.view]如果你在使用故事板,我不明白你为什么在appdelegate上这样做

  • 对于与顶栏重叠的tableview,请使用此选项以避免重叠

    viewController.edgesForExtendedLayout=UIRectEdgeNone

  • 对于self.Window部分,您的didFinishLoadingWithOptions应该如下所示

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window makeKeyAndVisible];
    [self.window setRootViewController:tbc]; //tab bars
    

    除了nsuinteger的答案外,表格单元格的
    detailLabel
    的问题在于没有指定正确的表格视图单元格样式:

    // default style
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    
    您需要
    UITableViewCellStyleSubtitle
    样式化单元格,并且您可能还需要为公开指示符设置
    accessoryType
    属性:

    // subtitle style
    cell = [[[UITableViewCell alloc] UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    

    我是否将
    viewController.edgesForExtendedLayout=UIRectEdgeNone在viewDidLoad中?我是否因为xCode不喜欢而更改viewController部分!这有助于我的风格,谢谢!然而,它仍然无法进入我的detailView。我已经检查了推到细节视图的所有连接可能与您的segue有关,这应该是一个单独的问题。
    
    // subtitle style
    cell = [[[UITableViewCell alloc] UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;