Gowhich

Durban's Blog

解决办法的流程是:

Open only XCode without opening project -> Go to Window -> Organizer -> [ProjectName] and delete it completely -> Quit XCode -> Open iPhone simulator and reset settings -> Quit iPhone simulator -> reboot Mac -> reopen XCode and run application

由于上个uivewcontroller的动画没做完,导致下一个的页面无法顺利压栈,这个只需要上一个页面返回的时候不要做动画就可以了。(这是其中的一种情况),

如果不想去掉这个动画,需要做动画的操作,该怎么办呢,我这里给出一篇文章的做法,基本上都是类似的,我这里贴出地址:

http://www.cfanz.cn/?c=article&a=read&id=23441

Xcode下创建一个项目,但是运行的时候出现了如下的错误:

1
2
clang: error: unable to execute command: posix_spawn failed: Resource temporarily unavailable
clang: error: clang frontend command failed due to signal (use -v to see invocation)

经过查找资料,有个说明是这样的,如下:

you may be running into too-low limits on the number of concurrent processes allowed on the machine. Check:

1
2
sysctl kern.maxproc
sysctl kern.maxprocperuid

You can increase them with e.g.:

1
2
sudo sysctl -w kern.maxproc=2500
sudo sysctl -w kern.maxprocperuid=2500

But normally this shouldn’t be necessary if you’re building on 10.7 or higher. If you see this, check if some rogue program spawned hundreds of processes and kill them first.

我按照上面的流程执行了操作:

1
2
3
4
5
6
7
8
9
davidzhang@davidzhang:~/command$ sysctl kern.maxproc
kern.maxproc: 1064
davidzhang@davidzhang:~/command$ sysctl kern.maxprocperuid
kern.maxprocperuid: 709
davidzhang@davidzhang:~/command$ sudo sysctl -w kern.maxproc=2500
Password:
kern.maxproc: 1064 -> 2500
davidzhang@davidzhang:~/command$ sudo sysctl -w kern.maxprocperuid=2500
kern.maxprocperuid: 709 -> 2500

最后运行我的项目的时候,问题就解决了

查询参考资料:http://code.google.com/p/chromium/wiki/MacBuildInstructions

这里说明,Ubuntu 中系统没有了RH系统中的 chkconfig 命令 !
可用一些小工具来管理 Ubuntu 的启动选项:

小工具 rcconf:

1
2
#sudo apt-get rcconf
#sudo apt-get install rcconf

root 下运行:

1
#sudo rcconf

功能更全的工具:

sysv-rc-conf

1
2
#sudo apt-get update
#sudo apt-get install sysv-rc-conf

运行:

1
#sudo sysv-rc-conf

也可以直接加入启动程序,例如把 /etc/init.d/red5 加入到系统自动启动列表中:

1
#sudo sysv-rc-conf red5 on

其他使用方法见: google::Ubuntu::sysv-rc-conf 命令用法
也可以直接修改
直接改 /etc/rc0.d ~/etc/rc6.d/etc/rcS.d 下的东西,S开头的表示启动,K开头的表示不启动,
例如:想关闭 Red5 的开机自动启动,只需 #sudo mv /etc/rc2.d/S20red5 /etc/rc2.d/K20red5 就可以了。

Ubuntu自动启动程序

首先,linux随机启动的服务程序都在/etc/init.d这个文件夹里,里面的文件全部都是脚本文件(脚本程序简单的说就是把要运行的程序写 到一个 文件里让系统能够按顺序执行,类似windows下的autorun.dat文件),另外在/etc这个文件夹里还有诸如名为rc1.d, rc2.d一直到rc6.d的文件夹,这些都是linux不同的runlevel,我们一般进入的X windows多用户的运行级别是第5级,也就是rc5.d,在这个文件夹下的脚本文件就是运行第5级时要随机启动的服务程序。需要注意的是,在每个rc (1-6).d文件夹下的文件其实都是/etc/init.d文件夹下的文件的一个软连接(类似windows中的快捷方式),也就是说,在 /etc/init.d文件夹下是全部的服务程序,而每个rc(1-6).d只链接它自己启动需要的相应的服务程序!

要启动scim (某一程序),我们首先要知道scim程序在哪里,用locate命令可以找到,scim在/usr/bin/scim这里,其中usr表 示是 属于用户的,bin在linux里表示可以执行的程序。这样,我就可以编写一个脚本程序,把它放到/etc/init.d里,然后在rc5.d里做一个相 应的软链接就可以了。
这个脚本其实很简单,就两行:

1
2
#!/bin/bash
/usr/bin/scim

第一行是声明用什么终端运行这个脚本,第二行就是要运行的命令。
还 需要注意的一点是,在rc5.d里,每个链接的名字都是以S或者K开头的,S开头的表示是系统启动是要随机启动的,K开头的是不随机启动的。这 样,你就可以知道,如果我要哪个服务随机启动,就把它名字第一个字母K改成S就可以了,当然,把S改成K后,这个服务就不能随机启动了。因此,我这个链接 还要起名为SXXX,这样系统才能让它随机启动。
在RH下,rc.local是默认启动的最后一个脚本文件,所以,
如果你想要随机启动,还有一种方法就是在rc.local的尾部加入/usr/bin/scim,这样就可以了。

Linux 自动启动程序

1.开机启动时自动运行程序
Linux 加载后, 它将初始化硬件和设备驱动, 然后运行第一个进程init。init根据配置文件继续引导过程,启动其它进程。通常情况下,修改放置在 /etc/rc/etc/rc.d/etc/rc?.d 目录下的脚本文件,可以使init自动启动其它程序。例如:编辑 /etc/rc.d/rc.local 文件(该文件通常是系统最后启动的脚本),在文件最末加上一行“xinit”或“startx”,可以在开机启动后直接进入X-Window。
2.登录时自动运行程序
用 户登录时,bash首先自动执行系统管理员建立的全局登录script :/ect/profile。然后bash在用户起始目录下按顺序查找三个特殊文件中的一个:.bash_profile.bash_login.profile,但只执行最先找到的一个。
因此,只需根据实际需要在上述文件中加入命令就可以实现用户登录时自动运行某些程序(类似于DOS下的Autoexec.bat)。
3.退出登录时自动运行程序
退出登录时,bash自动执行个人的退出登录脚本.bash_logout。例如,在.bash_logout中加入命令“tar -cvzf c.source.tgz *.c”,则在每次退出登录时自动执行 “tar” 命令备份 *.c 文件。
4.定期自动运行程序
Linux有一个称为crond的守护程序,主要功能是周期性地检查 /var/spool/cron目录下的一组命令文件的内容,并在设定的时间执行这些文件中的命令。用户可以通过crontab 命令来建立、修改、删除这些命令文件。
例如,建立文件crondFile,内容为“00 9 23 Jan * HappyBirthday”,运行“crontab cronFile”命令后,每当元月23日上午9:00系统自动执行“HappyBirthday”的程序(“*”表示不管当天是星期几)。
5.定时自动运行程序一次
定时执行命令at 与crond 类似(但它只执行一次):命令在给定的时间执行,但不自动重复。at命令的一般格式为:at [ -f file ] time ,在指定的时间执行file文件中所给出的所有命令。也可直接从键盘输入命令:

1
2
3
4
5
6
$ at 12:00  
at>mailto Roger -s ″Have a lunch″ < plan.txt
at>Ctr-D
Job 1 at 2000-11-09 12:00
2000-11-09 12:00时候自动发一标题为“Have a lunch”,内容为plan.txt文件内容的邮件给Roger。?9 12:00
2000-11-09 12:00时候自动发一标题为“Have a lunch”,内容为plan.txt文件内容的邮件给Roger。er。ger。er。

Ubuntu 开机自动挂载windows分区

要挂载NTFS格式分区,需要NTFS-3g这个软件。它短小精悍,而且功能强大。
NTFS-3g是一个开源软件,它支持在Windows下面读写NTFS格式的分区。它非常的快速,同时也很安全。它支持Windows 2000、XP和2003,并且支持所有的符合POSIX标准的磁盘操作。
首先要编辑sources.list

1
#sudo gedit /etc/apt/sources.list

Ubuntu Drapper添加:

1
2
3
deb http://givre.cabspace.com/ubuntu/ dapper main main-all
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ dapper main main-all
deb http://flomertens.keo.in/ubuntu/ dapper main main-all

Ubuntu Edgy添加:

1
2
3
deb http://givre.cabspace.com/ubuntu/ edgy main
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main
deb http://flomertens.keo.in/ubuntu/ edgy main

同时必须导入GPG-Key,可以这样:

1
2
#wget http://flomertens.keo.in/ubuntu/givre_key.asc -O- | sudo apt-key add -
#wget http://givre.cabspace.com/ubuntu/givre_key.asc -O- | sudo apt-key add -

现在更新一下源:

1
#sudo aptitude update

正式安装

在“终端”下面运行:

1
#sudo apt-get install ntfs-3g

配置NTFS-3g

首先看一些硬盘分区的分区类型

1
#sudo fdisk -l

现在就可以修改 /etc/fstab,来让Ubuntu启动的时候自动挂载NTFS分区了。但是首先请备份一下这个文件:

1
#sudo cp /etc/fstab /etc/fstab.bak

建立挂载点,譬如挂载在 /media/windows 下面

1
#sudo mkdir /media/windows

现在可以在 /etc/fstab 的后面添加

1
/dev/hda1 /media/ ntfs-3g defaults,locale=zh_CN.utf8 0 0

根据自己的情况进行修改。
一些示例

挂载 /dev/hda3

添加 /dev/hda3 /media/windows ntfs-3g ro,locale=zh_CN.utf8,uid=1000 0 0
关于自己的locale
可以用下面的命令查看所有的locale
#locale -a
如果不想重新启动,就可以

1
2
#sudo umount -a
#sudo mount -a

最后一个挂载FAT分区的命令

1
#sudo mount /dev/hda3 /media/windows/ -t vfat -o iocharset=utf8,umask=000

当然可以在/etc/fstab里面添加

1
/dev/hda3 /media/windows vfat iocharset=utf8,umask=000 0 0

Openfire随着Ubuntu自动启动

openfire缺省情况下,是不随机启动的。为了解决每次都要手工启动的麻烦,我编写了一个脚本,放在/etc/init.d目录里面

1
#sudo vim /etc/init.d/openfire

内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh
openfire_start(){
/etc/openfire/bin/openfire start
}
openfire_stop(){
/etc/openfire/bin/openfire stop
}
case $1 in
start)
openfire_start
;;
stop)
openfrie_stop
;;
*)
echo ‘Usage:openfire start|stop’
;;
esac

我的开机启动项设置为:

在/etc/rc.local中添加自己要执行的代码,如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#启动redis服务
/usr/local/bin/redis-server /etc/redis.conf
#启动uwsgi
/usr/local/bin/uwsgi --ini /etc/uwsgi.ini
#启动tomcat
/usr/tomcat/apache-tomcat-7.0.35/bin/startup.sh
exit 0

参考资料:http://www.cnblogs.com/ainiaa/archive/2011/12/05/2276989.html

安装python解释器(略)

安装PyDev

首先需要去Eclipse官网下载:http://www.eclipse.org/ ,Eclipse需要JDK支持,如果Eclipse无法正常运行,请到Java官网下载JDK安装:http://www.oracle.com/technetwork/java/javase/downloads。
打开Eclipse,找到Help菜单栏,进入Install New Software…选项。
点击work with:输入框的旁边点击Add…,Name可以随便是什么,我输入的是PyDev,Location是 http://pydev.org/updates 点击OK。
等待一下,便可以在选择栏里看到各个选项。
选择PyDev,然后一路Next,进入安装路径选择界面,使用默认设置,然后 Finish。Eclipse将下载 PyDev,可以从 Eclipse任务栏中看到下载的进度。
PyDev安装好后,需要重启Eclipse。

配置PyDev

PyDev安装好之后,需要配置解释器。在 Eclipse 菜单栏中,选择Window > Preferences > Pydev > Interpreter – Python,在此配置 Python。首先需要添加已安装的解释器。如果没有下载安装Python,请到官网下载2.x或者3.x版本:http://www.python.org/
我使用的是Python2.7版本。单击 New,进入对话框。Interpreter Name可以随便命名,
Interpreter Executable选择Python解释器/usr/bin/python。
点击OK后跳出一个有很多复选框的窗口,选择需要加入SYSTEM pythonpath的选项,点击Ok。
然后在Python Interpreters的窗口,再次点击OK,即完成了Python解释器的配置。
到此PyDev就已经完成了配置,可以使用Eclipse开始编写Python。
Hola World:
在 Eclipse 菜单栏中,选择File > New > Pydev > Project…,在窗口中选择PyDev Project,有三种项目可以创建,选择PyDev Project。
点击Next,输入项目名,选择相应的项目类型,以及所使用的Python语法版本和Python解释器。
创建成功后,进入透视图,右击src图标,选择New->Pydev Package,创建一个新的包。系统将自动生成__init__.py 文件,该文件不包含任何内容。再右键单击创建的包,选择 New->Pydev Module,创建你一个新的Python模块,单击Finish。

这样我们就可以开始创建第一个.py文件了。

更好的方法

在这个也页面 http://pydev.org/download.html ,你会看到某个软件已经预安装了这个扩展,她就是“Aptana Studio 3”

通过Core Library的文档,我们知道创建颜色有这么几个方法:

  • CGColorCreate
  • CGColorCreateCopy
  • CGColorCreateGenericGray
  • CGColorCreateGenericRGB
  • CGColorCreateGenericCMYK
  • CGColorCreateCopyWithAlpha
  • CGColorCreateWithPattern

再来看一下CGColorCreate:

1
2
3
4
CGColorRef CGColorCreate (  
CGColorSpaceRef colorspace,
const CGFloat components[]
);

我们通过CGColorCreate就可以创建颜色。既然我们要用RGB表示颜色,那么colorspace这个参数我们就可以使用CGColorSpaceCreateDeviceRGB(),而我们主要来探讨components这个参数。
这个参数是一个数组,带有4个数值:

float color[]={红色分量, 绿色分量, 蓝色分量, alpha分量};

这4个数值都是0-1区间,0表示黑(不发光),数字越大这种颜色的光线越强,alpha分量表示透明度。比如{1.0, 0, 0,1.0}就是纯红色而且完全不透明。

最终的使用方法,如下代码:

1
[UIColor colorWithRed:55.0/255.0 green:137.0/255.0 blue:195.0/255.0 alpha:1.0];

里面的值(55.0,137.0,195.0)可以自己选择,我是通过使用photoshop自己选择的,你也可以试试

首先引入文件:#import <QuartzCore/QuartzCore.h>

再次执行类似下面的代码:

1
2
3
4
5
6
UIButton *moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
moreButton.frame = CGRectMake(1.0f, 1.0f, cell.contentView.frame.size.width-2, cell.contentView.frame.size.height-2);
[moreButton.layer setMasksToBounds:YES];
[moreButton.layer setCornerRadius:10.0]; //设置矩形四个圆角半径
[moreButton.layer setBorderWidth:1.0]; //边框宽度
moreButton.backgroundColor = [UIColor clearColor];

在iOS开发中,经常遇到两个View之间互相切换,列举下各种方式,但是下面每种方式都要自己灵活运用,不一定就是进入下一个、后一个必须用“一”里面的方式。

进入下/后一个View

A:insertSubView系列:(注意,如果你新增视图不够大,则遮不住上一层视图,即前后2个视图都存在,当然你可以做透明来查看所有,与二A对应)

  • addSubview: (常用增加视图在本View上面)
  • bringSubviewToFront;将新视图放在其他同级视图的top位置
  • insertSubview:atIndex: 将新视图放在第index层,index是从底层向上数的下标位置
  • insertSubview:aboveSubview:将新视图放在第二个参数view的上面
  • insertSubview:belowSubview:将新视图放在第二个参数view的下面
  • exchangeSubviewAtIndex:withSubviewAtIndex:改变新视图从第一个位置到第二个位置

B:presentViewController系列:(常用视图切换,与二B对应)

  • presentViewController:animated:completion: 弹出,出现一个新视图 可以带动画效果,完成后可以做相应的执行函数经常为nil
  • presentModalViewController:animated: 弹出,出现一个新视图 可以带动画效果

C:UINavigationController系列:(常用导航栏视图切换,与二C对应)

  • pushViewController:animated: 推进一个新视图到栈里,出现新视图,可以带动画效果
    例 pushViewController:animated:

返回上/前一个View

A:insertSubView系列:(注意,如果你新增视图不够大,则遮不住上一层视图,即前后2个视图都存在,当然你可以做透明来查看所有,与一A对应)

  • sendSubviewToBack: 将新视图放在其他同级视图的behind位置
  • removeFromSuperview:将新视图从父视图上移除

B:presentViewController系列:(与一B对应)

  • dismissViewControllerAnimated:completion:退出一个新视图 可以带动画效果,完成后可以做相应的执行函数经常为nil
  • dismissModalViewControllerAnimated: 退出一个新视图 可以带动画效果

C:UINavigationController系列:(常用导航栏视图切换,与一C对应)

  • popViewControllerAnimated: 从一个栈中退出视图,返回上一层,可以带动画效果
  • popToRootViewControllerAnimated:从一个栈中退出视图,返回到navigation的RootView,可以带动画效果
  • popToViewController:animated:从一个栈中退出视图,返回到navigation中指定的view,可以带动画效果
    基本上上面已经介绍完全部常用视图切换方式:

UITabBarController:(需要先将几种视图在tabBar种设置好)

  • setViewControllers:animated:设置要出现的视图

  • selectedViewController 设置要出现的视图

  • selectedIndex 设置要出现的视图下标

来源:http://blog.csdn.net/u010335966/article/details/8858172

可以直接看代码,可以直接复制,自己运行:

VlinkageViewController.h(实现UITabBarDelegate)

VlinkageViewController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//
// VlinkageViewController.h
// xunYi
//
// Created by david on 13-5-3.
// Copyright (c) 2013年 david. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface VlinkageViewController : UIViewController<UITabBarDelegate>

@property (nonatomic, retain) UITabBar *tabBar;

@end

VlinkageViewController.m(关键一点是要实现[self.tabBar setDelegate:self],不然不起作用的)

VlinkageViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// VlinkageViewController.m
// xunYi
//
// Created by david on 13-5-3.
// Copyright (c) 2013年 david. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>
#import "VlinkageViewController.h"

@interface VlinkageViewController ()


@end

@implementation VlinkageViewController

@synthesize tabBar;

- (void)viewDidLoad
{
[super viewDidLoad];
//判断机体的宽度和高度
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat width = screenBounds.size.width;
CGFloat height = screenBounds.size.height;
#pragma 添加tabBar
CGFloat tabBarHeight = 40;
CGFloat tabBarY = height - tabBarHeight - searchBar.frame.size.height / 2;
self.tabBar = [[UITabBar alloc] initWithFrame:
CGRectMake(0, tabBarY, width, tabBarHeight)];
[self.tabBar setDelegate:self];

//设置切换title
UITabBarItem *tabBarItem1 = [[UITabBarItem alloc] initWithTitle:@"查找" image:nil tag:0];
UITabBarItem *tabBarItem2 = [[UITabBarItem alloc] initWithTitle:@"我的关注" image:nil tag:1];
UITabBarItem *tabBarItem3 = [[UITabBarItem alloc] initWithTitle:@"咨询" image:nil tag:2];
UITabBarItem *tabBarItem4 = [[UITabBarItem alloc] initWithTitle:@"更多" image:nil tag:3];

NSLog(@"tabBarItem1.tag = %d",tabBarItem1.tag);
NSLog(@"tabBarItem1.tag = %d",tabBarItem2.tag);
NSLog(@"tabBarItem1.tag = %d",tabBarItem3.tag);
NSLog(@"tabBarItem1.tag = %d",tabBarItem4.tag);

//数组形式添加进 tabBar
NSArray *tabBarItemArray = [[NSArray alloc]
initWithObjects:tabBarItem1, tabBarItem2, tabBarItem3, tabBarItem4, nil];
[self.tabBar setItems:tabBarItemArray];
[self.view addSubview:self.tabBar];

}

-(void) tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
NSLog(@"item.tag= %d", item.tag);
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end

最近写一个程序时,不知道怎么弄的,不能build到真机了,到模拟器没有什么问题,出现的错误是 : 研究可很长时间,也没有弄明白,在网上也着了很多资料,说是enable 了 guardmalloc

1
could not load inserted library: /usr/lib/libgmalloc.dylib

在xcode里面找了很久也没有着到怎么关闭, 最后无意中 发现了关闭他的方法,问题也解决了.
方法:
菜单–>Product—>EditScheme, 左边框 有一个列表,点击 run xxx.app , 你会发现在右边 Diagnostics里 有一些checkbox, 第三行 便是 关闭 Guard Malloc,
保险起见,clean 下工程,重新build 下 就ok了.

0%