1. 获取当天日期

NSDate *today;

today = [NSDate date];

 

2.[[UIDevice currentDevice] orientation] 通过这个获取设备状态是有以下七个状态:

UIDeviceOrientationUnknown                 

UIDeviceOrientationPortrait                    //Device oriented vertically, home button one the button

UIDeviceOrientationPortraitUpsideDown   //Device oriented vertically, home button one the top

UIDeviceOrientationLandscapeLeft           //Device oriented horizontally,home button on the right

UIDeviceOrientationLandscapeRight         //Device oriented horizontally, home button on the left

UIDeviceOrientationFaceUp                     //Device oriented flat, face up

UIDeviceOrientationFaceDown                 //Device oriented flat, face down

在有第一个和最后两个状态的情况下,如果是在状态发生变化的时候去做一些操作,那么是没问题的,因为操作的时候只捕获四个旋转状态即可。但是如果要根据在做操作的时候根据状态去做某些事情就会有问题,因为非常有可能取到那三个非旋转状态。解决方案:记住上一个旋转状态,当发现获取的状态不是四个旋转状态的时候,使用上一个正常旋转状态。

- (void)applicationDidFinishLaunching:(UIApplication *)application {

   [window addSubview:crateViewController.view];
	
   [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
	
   [[NSNotificationCenter defaultCenter] addObserver:self
      selector:@selector(orientationChanged:)
      name:@"UIDeviceOrientationDidChangeNotification" object:nil];
}
- (void)orientationChanged:(NSNotification *)notification
{
  UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
  if (UIDeviceOrientationIsPortrait(orientation) || UIDeviceOrientationIsLandscape(orientation))
  {
    if (!currentOrientation)
    {
      currentOrientation = orientation;
      [self prepareScreen];
    }
    currentOrientation = orientation;
  }
  [[UIApplication sharedApplication] setStatusBarOrientation:currentOrientation animated:YES];
}

3.UIButton 能吃掉所有的Touches事件,暂时还没有找到穿透的方法。

说明:在UIView中放置一个UIButton,这个UIButton的大小和UIView的大小和位置完全一致,这样的话UIView本身拥有的touchesBegan: touchesMoved:touchesEnded:等等事件全部都不能捕获到了。如果有相应的业务需求怎么办呢,建议用UIImageView, 通过touchesBegan和TouchesEnden事件来改变图片的资源,这样的话,也能达到button的点击效果了。

posted on 2010-07-20 09:58  痴鸟  阅读(2785)  评论(0编辑  收藏  举报