Vấn đề thực sự đến, khi giao diện của bạn xoay ngang và bộ điều khiển xem mẹ có một sự biến đổi trên nó. Hãy tin tôi, đó là một kịch bản thực tế, doh. Sau đó, bảng hành động được cắt bớt và bạn không thể sử dụng parentViewController vì nó được chuyển đổi. Giải pháp để tránh tất cả những vấn đề này là tạo một cửa sổ mới, thêm một bộ điều khiển dạng xem xoay như rootViewController và sử dụng khung nhìn của nó để hiển thị trang tính.
CGRect applicationRect = [[UIScreen mainScreen] bounds];
UIWindow* actionSheetWindow = [[UIWindow alloc] initWithFrame:applicationRect];
RotationViewController* rootViewController = [[RotationViewController alloc] initWithNibName:nil bundle:nil];
actionSheetWindow.rootViewController = rootViewController;
[rootViewController release];
actionSheetWindow.hidden = NO;
UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:nil];
[actionSheet setCancelButtonWithTitle:@"Cancel" handler:^{
actionSheetWindow.hidden = YES;
[actionSheetWindow release];
}];
[actionSheet showInView:rootViewController.view];
Đoạn mã trên sử dụng BlocksKit, nhưng bạn cũng có thể làm điều đó bằng cách sử dụng thuộc tính instance và ủy quyền actionSheet.
RotationViewController chỉ là một lớp con UIViewController mà thực hiện
- (void) viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor clearColor];
self.view.opaque = NO;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
Nguồn
2012-01-11 11:32:19
Xin vui lòng gửi một số mã của bạn, sau đó một cách dễ dàng, chúng tôi có thể giúp bạn giải quyết nó. – jfalexvijay
Bạn không thể sử dụng bất kỳ phương thức showFromTabBar nào, nếu bạn đang sử dụng một số thanh tab tùy chỉnh. stackr nói với các cược trả lời! –
@ WinDMak3r - Vâng tôi biết và đó là lý do tại sao anh ta có 32 phiếu bầu :) – Saawan