当前位置: 编程技术>移动开发
本页文章导读:
▪override的简略示例 override的简单示例
overrideAppDelegate.h
#import <UIKit/UIKit.h>
@interface overrideAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end
overr.........
▪ 应用程序动态全屏跟退出全屏 应用程序动态全屏和退出全屏
让程序全屏的方法,大家都知道,那是静态的,程序运行之初就申明了。但是如果有这样的需求:要在程序运行的过程中,执行了某个操作而使之全屏.........
▪ 小结了一些经常涉及到的权限 总结了一些经常涉及到的权限
http://topic.csdn.net/u/20101116/10/ecb5fde2-39dc-44d0-a901-eb8b70d845f5.html访问网络的权限:<uses-permission android:name="android.permission.INTERNET" ></uses-permission>添加WiFi以.........
[1]override的简略示例
来源: 互联网 发布时间: 2014-02-18
override的简单示例
overrideAppDelegate.h
#import <UIKit/UIKit.h> @interface overrideAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; } @property (nonatomic, retain) IBOutlet UIWindow *window; @end
overrideAppDelegate.m
#import "overrideAppDelegate.h" #import "NSString+Addition.h" @implementation overrideAppDelegate @synthesize window; #pragma mark - #pragma mark Application lifecycle - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [window makeKeyAndVisible]; if ([NSString swizze]) { NSString *s1 = @"Hello, everyone"; char *s2 = (char *)[s1 UTF8String]; NSLog(@"%s", s2); } return YES; } #pragma mark - #pragma mark Memory management - (void)dealloc { [window release]; [super dealloc]; } @end
NSString+Addition.h
#import <Foundation/Foundation.h> @interface NSString (NSString_Addition) + (BOOL)swizze; @end
NSString+Addition.m
#import "NSString+Addition.h" #import <objc/objc-class.h> #define CSTRING_CUSTOM_ADDITON "^_^" @implementation NSString (NSString_Addition) - (const char *)ovUTF8String { char *sOriginal = (char *)[self ovUTF8String]; int iOrgLen = (NULL == sOriginal ? 0 : strlen(sOriginal)); char *sCustom = (char *)malloc(iOrgLen + strlen(CSTRING_CUSTOM_ADDITON) + 1); if (NULL != sCustom) { if (NULL != sOriginal) { strcpy(sCustom, sOriginal); } strcat(sCustom, CSTRING_CUSTOM_ADDITON); } return (const char *)sCustom; } + (BOOL)swizze { Method oldMethod = class_getInstanceMethod(self, NSSelectorFromString(@"UTF8String")); if (!oldMethod) return NO; Method newMethod = class_getInstanceMethod(self, NSSelectorFromString(@"ovUTF8String")); if (!newMethod) return NO; method_exchangeImplementations(oldMethod, newMethod); return YES; } @end
[2] 应用程序动态全屏跟退出全屏
来源: 互联网 发布时间: 2014-02-18
应用程序动态全屏和退出全屏
让程序全屏的方法,大家都知道,那是静态的,程序运行之初就申明了。但是如果有这样的需求:要在程序运行的过程中,执行了某个操作而使之全屏,然后还需要退出全屏,怎么做?
如下:
修改window的LayoutParams参数,然后加上FLAG_LAYOUT_NO_LIMITS标志,就OK了。window会自动重新布局,呈现全屏的状态。
要退出全屏,只需要清除刚才加上的FLAG_FULLSCREEN参数,然后去掉FLAG_LAYOUT_NO_LIMITS标志。
如下:
让程序全屏的方法,大家都知道,那是静态的,程序运行之初就申明了。但是如果有这样的需求:要在程序运行的过程中,执行了某个操作而使之全屏,然后还需要退出全屏,怎么做?
如下:
WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; getWindow().setAttributes(attrs); getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
修改window的LayoutParams参数,然后加上FLAG_LAYOUT_NO_LIMITS标志,就OK了。window会自动重新布局,呈现全屏的状态。
要退出全屏,只需要清除刚才加上的FLAG_FULLSCREEN参数,然后去掉FLAG_LAYOUT_NO_LIMITS标志。
如下:
WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setAttributes(attrs); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
[3] 小结了一些经常涉及到的权限
来源: 互联网 发布时间: 2014-02-18
总结了一些经常涉及到的权限
http://topic.csdn.net/u/20101116/10/ecb5fde2-39dc-44d0-a901-eb8b70d845f5.html
访问网络的权限:
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
添加WiFi以及访问网络的权限:
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" ></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" ></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" ></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" ></uses-permission>
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" ></uses-permission>
操作外部存储设备文件:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
录音时需要的权限:
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
录制视频时需要的权限:
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
发送短信:
<uses-permission android:name="android.permission.SEND_SMS" ></uses-permission>
收短信:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
收彩信:
<uses-permission android:name="android.permission.READ_SMS" />
GPS:
<!-- 權限 : 上網連線 -->
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<!-- 權限 : GPS定位 -->
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<!-- 權限 : AGPS定位 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
http://topic.csdn.net/u/20101116/10/ecb5fde2-39dc-44d0-a901-eb8b70d845f5.html
访问网络的权限:
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
添加WiFi以及访问网络的权限:
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" ></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" ></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" ></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" ></uses-permission>
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" ></uses-permission>
操作外部存储设备文件:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
录音时需要的权限:
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
录制视频时需要的权限:
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
发送短信:
<uses-permission android:name="android.permission.SEND_SMS" ></uses-permission>
收短信:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
收彩信:
<uses-permission android:name="android.permission.READ_SMS" />
GPS:
<!-- 權限 : 上網連線 -->
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<!-- 權限 : GPS定位 -->
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<!-- 權限 : AGPS定位 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
最新技术文章: