English 中文(简体)
提出和改变看法
原标题:Rotating iPhone and changing views

我从来就没有在地毯中玩.,但我有一个完全有效的手法,假设用户正在看清地毯。 我愿以轮流电话为主,为了做到这一点,我非常简单:

我在我的主计长面前加上以下守则:

-(void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
    NSLog(@"WILL ROTATE TO INTERFACE ORIENTATION: %@",orientation);

    if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight))
        tableView.frame = CGRectMake(0, 0, 480, 320);
    else
        tableView.frame = CGRectMake(0,73,320,390);


}

和I m 发现BAD_ACCESS错误。 我根本看不到观点的负荷。 因此,问题何在,我如何妥善执行“意愿”方法,以便在电话轮换时,我能够把我的所有部分转成一体?

最佳回答

坠毁的原因是:

NSLog(@"WILL ROTATE TO INTERFACE ORIENTATION: %@",orientation);

<编码>/代码>为<代码>enum数值,因此,格式查询人应为%i not%@

支持轮换的最简单办法是:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

您希望支持的返回代码。 在这种方法中不作任何改观。 利用这些观点,确保这些意见在轮流时能够正确地加以改变和重新定位。

问题回答

It s a problem with your logging code:

NSLog(@"WILL ROTATE TO INTERFACE ORIENTATION: %@",orientation);

您的伐木体中的光谱仪表%@NSString指点。 当该信达到这一点时,它审视了方向变量,试图将其引向<条码>NSString例,并坠毁,因为它根本不是点人,它具有重大价值。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签