Question: I need to convert an Array List to Object[][], I have tried several different methods, and all seem to toss up an error or two.

My latest try is this:

```
Object[][] array = dataList.toArray(new Object[dataList.size()][]);

```

This throws the following error:

```none
java.lang.ArrayStoreException
    at java.lang.System.arraycopy(Native Method)
    at java.util.ArrayList.toArray(Unknown Source)

```

My array list is populated with classes I made, this is the class:

```
class dataClass {
    int x;
    int y;
    int z;
    String string1;
    String string2;
    Date date;
    int event;

    public dataClass(int x, int y, int z, String string1, String string2,
            Date date, int event) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.string1 = string1;
        this.string2 = string2;
        this.date = date;
        this.event = event;
    }
}

```

This is how I initialize my array list:

```
public static List<dataClass> dataList = new ArrayList<dataClass>();

```

I then add my new dataClass via:

```
.add(new dataClass(...));

```

Any help would be great, thanks.

Answer: 
I temporarily solved (through a *hack*) with the following code in the `viewDidLoad` of my controller. I have to specify that the code is specifically made for my case: since I explicitly disallow landscape orientation of my UINavigationController (see code above), the usual notification “UIDeviceOrientationDidChange” is not called when the playback finished and the window goes back to portrait. However, I hope there is a better option and this is a bug of the SDK, since it does not appear on iOS 7 and given the amount of auto-layout errors I get related to the video player (on which I have no control).

```
- (void)viewDidLoad
{
    [super viewDidLoad];

    // […]

     /* 
     Hack to fix navigation bar position/height on iOS 8 after closing fullscreen video

     Observe for “UIWindowDidRotateNotification” since “UIDeviceOrientationDidChangeNotification” is not called in the present conditions
     Check if the notification key (“UIWindowOldOrientationUserInfoKey”) in userInfo is either 3 or 4, which means the old orientation was landscape
     If so, correct the frame of the navigation bar to the proper size.

     */
    [[NSNotificationCenter defaultCenter] addObserverForName:@"UIWindowDidRotateNotification" object:nil queue:nil usingBlock:^(NSNotification *note) {
        if ([note.userInfo[@"UIWindowOldOrientationUserInfoKey"] intValue] >= 3) {
            self.navigationController.navigationBar.frame = (CGRect){0, 0, self.view.frame.size.width, 64};
        }
    }];
}

```

And then…

```
- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self forKeyPath:@"UIWindowDidRotateNotification"];
}

```
On iOS 11 accepted solution didn't work for me. Seems that navigation bar stops reflecting for frame changes. But there is a workaround. At first, we need to modify `supportedInterfaceOrientationsForWindow` method to return `UIInterfaceOrientationMaskLandscape` for video controllers instead of `UIInterfaceOrientationMaskAllButUpsideDown`. In my case when I tap on embedded YouTube video, system always opens AVFullScreenViewController, so I removed other checks from original example. Code:

```
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    __kindof UIViewController *presentedViewController = [self topMostController];

    // Allow rotate videos
    NSString *className = presentedViewController ? NSStringFromClass([presentedViewController class]) : nil;
    if ([className isEqualToString:@"AVFullScreenViewController"]) {
        return UIInterfaceOrientationMaskLandscape;
    }

    return UIInterfaceOrientationMaskPortrait;
}

```

This didn't changes behaviour of AVFullScreenViewController on iOS 10 and less, but fixes navigation bar on iOS 11, so there is no need to update frame (also there is a side-effect on iOS 11 that video rotates from landscape when starts playing, but it's a tradeoff). Next, we need to add check in `UIWindowDidBecomeHiddenNotification` method:

```
- (void)videoDidExitFullscreen {
    if (@available(iOS 11, *)) {
        // Fixes status bar on iPhone X
        [self setNeedsStatusBarAppearanceUpdate];
    } else {
        self.navigationController.navigationBar.frame = CGRectMake(0, 0, self.view.bounds.size.width, statusAndNavBarHeight);
    }
}

```

Without `setNeedsStatusBarAppearanceUpdate` text in status bar will not appear on iPhone X, for other devices it's not needed.