1. Obtain the date of the current day
Nsdate * today;
Today = [nsdate date];
2. [[uidevice currentdevice] orientation] the following seven statuses are available for obtaining device statuses:
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
In the first and last states, if you perform some operations when the status changes, it is okay, this is because only four rotating states can be captured during the operation. However, if you want to do something according to the status during the operation, it will be problematic, because it is very likely that the three non-rotating states will be obtained. Solution: Remember the previous rotation status. When the obtained status is not four, use the previous normal rotation status.
- (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 can eat all touches events, and no penetrating method has been found yet.
Note: place a uibutton in the uiview. The size and position of the uibutton are exactly the same as that of the uiview. In this case, the touchesbegan: touchesmoved: touchesended of the uiview itself: and so on. If you have business requirements, we recommend that you use uiimageview to change the image resources through the touchesbegan and touchesenden events. In this way, the button clicking effect can also be achieved.