2013-10-04 31 views
5

Hiện tại, khi một nút được nhấn vào, một UIModalPresentationSheet xuất hiện. Tôi muốn thêm một thanh điều hướng ở trên cùng của điều này khi nó trượt lên. Tôi đã thử rất nhiều thứ nhưng không có gì có vẻ hiệu quả. Đây là những gì tôi hiện đang cố gắng và nó trả về lỗi này.Bộ điều hướng trong chế độ xem phương thức

AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:@"addAthlete"]; 
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete]; 
    //[self.navigationController pushViewController:addAthlete animated:YES]; 

    addAthlete.delegate = self; 
    addAthlete.modalPresentationStyle = UIModalPresentationFormSheet; 
    // UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addAthlete]; 
    [self presentViewController:navigationController animated:YES completion:nil]; 

Nhưng nó đẩy nó lên một cách bình thường và không có biểu mẫu dưới dạng modalpresentations. Làm thế nào tôi có thể làm cho nó để điều khiển chuyển hướng có kích thước chính xác?

Trả lời

12

Cố gắng thay đổi mã của bạn như thế này:

AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:@"addAthlete"]; 
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete]; 

    addAthlete.delegate = self; 
    navigationController.modalPresentationStyle = UIModalPresentationFormSheet; 


    [self presentViewController:navigationController animated:YES completion:nil]; 

Bởi vì ở đây, bạn cố gắng trình bày addAthlete từ chính nó. Vì vậy, bạn nhận được lỗi này.

+0

này hoạt động, nhưng nó không còn là một modalsheetpresentation .. –

+0

Có một cái nhìn để chỉnh sửa của tôi;) –

4

Bạn nên trình bày navigationController trong đó bạn đã bọc addAthlete của mình.

[self presentViewController:navigationController animated:YES completion:nil]; 
0

Bạn đang trình bày từ chính chế độ xem hiện tại.

Hãy thử một cái gì đó như thế nào,

[self dismissViewControllerAnimated:YES completion:^{ 
    [self.parentViewController presentViewController: navigationController animated:YES completion:nil]; 
}]; 
Các vấn đề liên quan