iPad开发

iPad开发.
这里主要是列出和iPhone开发的一些区别.
1.iPad的状态栏转屏之后,高度不会变.而且状态栏只能是黑色.
2.独属于iPad的类.
splitViewController
UIPopoverController

相对于iPhone来说, iPad应用基本都要求适应四个方向.
对于view来说, 只有两个情况
1.直接或间接加入到window上.
2.直接或间接加入到rootviewcontroller上.
为什么要这样区分呢?
因为系统会自动给rootviewcontroller的view做转屏.
当然前提是你的shouldAutorotateToInterfaceOrientation返回为YES.
这种情况,系统已经给你做转屏了..你要做的事只有一个, 重新设置大小和位置.也就是frame.

那对于没有通过rootviewcontroller而添加到window上的view呢..
没有办法, 自己去监听UIDeviceOrientationDidChangeNotification 事件吧.
监听到事件之后, 有两件事你得做:
1. 根据[[[UIApplication sharedApplication].statusBarOrientation] 对view做transform.

– (CGAffineTransform)transformForOrientation
{
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft)
{
return CGAffineTransformMakeRotation(M_PI*1.5);
}
else if (orientation == UIInterfaceOrientationLandscapeRight)
{
return CGAffineTransformMakeRotation(M_PI/2);
}
else if (orientation == UIInterfaceOrientationPortraitUpsideDown)
{
return CGAffineTransformMakeRotation(-M_PI);
}
else
{
return CGAffineTransformIdentity;
}
}
2.当然是设置frame了.

拍照:
这里要涉及到UIPopoverController了.
因为从图片库选择照片时, 只能把UIImagePickerController放到UIPopoverController里.
这里要注意的是- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;
这里面 rect怎么填..其实很简单, 就是后面参数view的bounds即可.