毛蛋(maoegg)网

——只为技术而存在

正在浏览由 weiwei 发布的文章

最近项目中遇到了一个问题,第三方授权和发微博。在网上找了个例子,挺全面的,有新浪,豆瓣,腾讯和twitter的。
这个是项目的具体下载地址 http://115.com/file/c2d5wxb8

于是就把它加入自己的项目中了,但是项目在进行授权完成之后死活回不到自己的程序。
最后发现其实很简单 这个项目中有个plist文件 只要修改下这个地方就行

项目中有一个文件专门用来定义一些url 的 其中有这个回调url

#define CallBackURL @”oauth://minroad.com”  //回调url

只要修改你自己的plist文件和这个对应就行了

该项目还在进行中 会不断更新的 ———-

在进行项目开发的时候图片的处理也是相当常见的一个功能 openflow就是主要用来处理图片显示的

该程序实现效果是这样的

首先附上一个下载该库的地址http://115.com/file/clyu8xf6

接着就是创建一个简单的工程 我在这里直接创建了一个基于view的工程

视图控制器类要遵循两个协议

<AFOpenFlowViewDataSource, AFOpenFlowViewDelegate>

在该类中加入如下代码

- (void)viewDidLoad {

[(AFOpenFlowView *)self.view setNumberOfImages:40]; //其实此处在xib中把self.view的类变成了AFOpenFlowView 这个应该都会的吧

for (int i=0; i<=40; i++) {

UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"t%d.jpg",i%6]];

[(AFOpenFlowView *)self.view setImage:image forIndex:i];

}

[super viewDidLoad];

}

//这样就可以实现比较炫的图片展示效果了

最近在做xml解析的程序 可是出现
提示找不到该文件 找了半天才解决
具体的做法是
在target 中添加的header file search path 如下图
然后添加libxml.dylib 再编译运行就不会报错了

今天用到了关于 UITabBarController,看到设计图中的那些效果和系统默认的不一样 所以赶紧上网找些资料去

发现关于它的自定义不少 可是好用的不是很多 大部分都是一样的 并且我用了之后效果不是很明显

但是经过看别人的 总算是组合出来了点结果

首先是修改背景

{

self.tabBarController = [[UITabBarController alloc] init];

//定义一个view 里面是一个背景图片

UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 49)];

v.backgroundColor  = [UIColor clearColor]; 继续阅读

navigationItem的背景修改方法

网上介绍最多的方法是使用分类 但是我用着的时候 不是每次都管用 但是还是先把这个方法写一下吧 毕竟也成功过。

@implementation UINavigationBar (UINavigationBarCategory)

- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"new-nav-bg.png"];
[image drawInRect:rect];
}
@end
如果该方法好用的话 后面添加左右按钮和设置标题就很简单了
// 设置标题
self.navigationItem.title = @”测试;

// 设置左边的按钮

UIBarButtonItem *returnButton = [[UIBarButtonItem alloc]initWithTitle:@”返回 style:UIBarButtonItemStyleBordered target:self action:@selector(returnMain)];

self.navigationItem.leftBarButtonItem = returnButton;

[returnButton release];

//定义右边按钮

UIBarButtonItem *diquButtons = [[UIBarButtonItem alloc]initWithTitle:@”编辑 style:UIBarButtonItemStyleBordered target:self action:@selector(selectArea)];

self.navigationItem.rightBarButtonItem = diquButtons;

self.diquButton = diquButtons;

[diquButtons release];

[temp release];

但是如果该方法不是很好用的话 只有用这个方法了

- (void)initNavBarItems:(NSString *)titlename{

// 设置navbar的titleview

UIView *dd = [[UIView alloc]initWithFrame:CGRectMake(-5, 0, 325, 44)];

UIImageView *imgs = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"new-nav-bg.png"]];

imgs.frame = CGRectMake(-5, 0, 325, 44);

[dd addSubview:imgs];

// 设置标题

UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(-5, 3, 320, 40)];

title.text = titlename;

title.textAlignment = UITextAlignmentCenter;

title.backgroundColor = [UIColor clearColor];

title.textColor = [UIColor whiteColor];

title.font = [UIFont boldSystemFontOfSize:22];

[dd addSubview:title];

// 设置左边的按钮

UIButton *left = [UIButton buttonWithType:UIButtonTypeRoundedRect];

left.frame = CGRectMake(15, 5, 60, 30);

[dd addSubview:left];

}
这样做的话 可以设置下标题 也能修改背景图 稍微有点复杂
如果对于一个比较大的项目的话 最好写一个公共类 然后设置它的navbar 然后让所有的导航视图控制器类都继承这个类 这样的话比较方便

editButton = [[UIBarButtonItem alloc] initWithTitle:@”编辑” style:UIBarButtonItemStyleBordered target:self action:@selector(editAction)];

self.navigationItem.rightBarButtonItem = editButton;

}

-(void)ToReturn

{

[self.navigationController popViewControllerAnimated:YES];

}

- (void)editAction{

if (editButton.title == @”编辑”) {

[editButton setTitle:@"确定"];

[editButton setStyle:UIBarButtonItemStyleDone];

[self.roadTable setEditing:YES animated:YES];

} 继续阅读

关于iphone的应用太多了 我就把自己以前项目中用到的列出来了

1. 判断设备的类型 pad 或者 iphone 并在main中定义一个宏来记录即可

#define IS_IPAD ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

2    调用 自带mail

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@maoegg.com"]];

调用 电话phone

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];   telprompt://11111   这样可以回到原来的程序中了

调用 SMS 继续阅读