NCAppDelegate.h
#import <UIKit/UIKit.h>
@interface NCAppDelegate : UIResponder <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) UITabBarController *tabBarController;
@end
NCAppDelegate.m
@synthesize window;
@synthesize tabBarController;
- (void)dealloc
{
[window release];
[tabBarController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
tabBarController = [[UITabBarController alloc] init];
HomeViewController *vc1 = [[HomeViewController alloc] init];
MetionsViewController *vc2 = [[MetionsViewController alloc] init];
FavoritesViewController *vc3 = [[FavoritesViewController alloc] init];
ProfileViewController *vc4 = [[ProfileViewController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2,vc3,vc4, nil];
tabBarController.viewControllers = controllers;
[window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
HomeViewController.m
@implementation HomeViewController
- (id)init {
if (self = [super init]) {
self.title = @"主页";
UIImage* anImage = [UIImage imageNamed:@"home_default.png"];
UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"主页" image:anImage tag:0];
self.tabBarItem = theItem;
[theItem release];
}
return self;
}
使用for循环递归累加其内部的子控件的高度:
private ScrollView scrollView;
scrollView = (ScrollView) findViewById(R.id.scrollview);
int h = 0;
for (int i = 0; i < scrollView.getChildCount(); i++) {
h += scrollView.getChildAt(i).getHeight();}
Bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h,
Bitmap.Config.ARGB_8888);
// Bitmap bitmap = scrollView.getDrawingCache(true);
final Canvas c = new Canvas(bitmap);
scrollView.draw(c);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
final byte[] picture = stream.toByteArray();
if (bitmap != null && !bitmap.isRecycled()) {
bitmap = null;// 把原来的 bitmap.recycle().改成这个
}
代码如上即可给Scrollview进行截屏并转换为bitmap,和byte[]数组,你可以根据自己需要选择使用·········
Mac 的开机时,按住一些按键可以发生奇妙的事情,有些按键我们使用的比较多,比如“Option”键,但有些按键我们使用的次数比较少,容易遗忘。
C 你可以从CD或DVD启动你的电脑,一般重装恢复系统、或进行iDefrag操作时会用到。
D 如果你的Mac安装盘在光区中,按这个键会让Mac进行硬件自检。
N 从网络服务器启动。这个功能只有在你拥有一个服务器时才会有用。
T 这个按键非常有用,它可以以目标盘模式启动,当你用火线把两台Mac电脑连结在一起时,按住这个键启动后你的电脑就成了一块大硬盘,通过另一台电脑可以对其进行数据恢复、硬盘对拷、重整分区等操作,有时候,当你的Mac无法通过光盘进行安装的时候(比如安装盘版本不对),通过另一台电脑进行系统安装会成为你的救命稻草。
Option 将调出启动管理器,你可以选择从哪个系统启动,那些用过BootCamp的朋友几乎都知道这个键,用这个键也可以选择从光盘启动,也就是代替C键。
Option 然后 N 这个功能同Option的功能差不多,唯一的区别是你可以选择是否从网络服务器启动。
Option + N 将从第一个可用的网络服务器启动。
Command + V 以详细模式启动,感觉有点像Windows下的命令行模式,让你都知道Mac在启动过程中都干了些啥,同样的,这种模式下当Mac关机时也会显示详细的文字说明。
Command + S 以单用户模式启动。通过这种模式,你可以运行一些风险较大的程序,在这种模式下,你可能在很短的时间内就把自己的电脑搞崩溃。
Shift 安全模式。这个按键也非常有用,它可以让一些不必须的启动项及硬件环境不自动加载,可以帮助你更好地判断你的问题出在哪里。当你的电脑无法启动时,试试安全模式。
Option + Command + P + R 重置PRAM,当Mac的PRAM意外损害时,可能致使你的电脑不稳定,这时候,你可以试试这四个神奇的按键。开机后立刻按住,然后听到第二声开机钟声时松开,电脑会重置PRAM,有时候一些奇怪的问题会得到解决。
按住 Eject(就是那个弹出光盘的键) 或 F12 或 鼠标 将弹出任何磁盘驱动器里的东西。请注意三个按键是“或”的关系,按其中任何一个就可。