//按钮事件
-(IBAction)btnRead
{
UIAlertView* a=[[UIAlertViewalloc]init];
a=[[UIAlertViewalloc] initWithTitle:@"b"message:@"s"delegate:selfcancelButtonTitle:@"确定"otherButtonTitles: @"取消",nil];
[a show];
}
//定义的委托,buttonindex就是按下的按钮的index值
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%i",buttonIndex);
}
posted @ 2012-03-29 12:00 凡娃软件 阅读(18) 评论(0) 编辑
//Web Service Call
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<SOAP-ENV:Envelope \n"
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \n"
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
"xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" \n"
"SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" \n"
"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n"
"<SOAP-ENV:Body> \n"
"<GetData xmlns=\"http://tempuri.org/\">"
"</GetData> \n"
"</SOAP-ENV:Body> \n"
"</SOAP-ENV:Envelope>"];


//[[NSURLCache sharedURLCache] removeAllCachedResponses];
NSURL *url = [NSURL URLWithString:@"http://192.168.1.20:86/Service1.svc"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/IService1/GetData" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

if(theConnection) {
webData = [[NSMutableData data] retain];
}
else {
NSLog(@"theConnection is NULL");
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[webData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[webData appendData:data];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
label.text = [NSString stringWithFormat:@"Connection failed: %@", [error description]];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSLog(@"Data has been loaded");
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:webData];
[parser setDelegate:self];
[parser parse];
[webData release];
}

- (void)parserDidStartDocument:(NSXMLParser *)parser {

}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {
currentElement = elementName;
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {


NSString *fixedString = [string stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];

if ([currentElement isEqualToString:@"GetDataResult"])
{
label.text=@"";
UIAlertView *view = [[UIAlertView alloc] initWithTitle:@"调用wcf成功!" message:fixedString delegate:nil cancelButtonTitle:nil otherButtonTitles:nil] ;
[view show];
[view release];
}

}
posted @ 2012-03-16 17:42 凡娃软件 阅读(27) 评论(0) 编辑

一般都是开启arc功能,毕竟不需要自己手动去释放,是一件比较轻松的事情。

但是我们在引用第三方的时候,基本上都是带release与retain的方法,这个时候代码编译就通不过

我们可以设置部分文件不使用arc,这样就可以兼容了。

步骤:

1.在builde phases 中,compile sources  

2.选中文件,双击文件,在弹出框中输入-fno-objc-arc,

3.编译就可以通过了

posted @ 2012-03-12 16:00 凡娃软件 阅读(120) 评论(0) 编辑

谢谢lamo的提醒,这个5.0确实无效。

//添加5.0下需加入的代码

    if ([self.navigationController.navigationBar respondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"check_yes.png"] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setTintColor:[UIColor redColor]];
}



 

 

CustomNavgationBar.m

@implementation UINavigationBar (UINavigationBarCategory)

- (void)drawRect:(CGRect)rect {
//颜色填充
//UIColor *color = [UIColor greenColor];
//CGContextRef context = UIGraphicsGetCurrentContext();
//CGContextSetFillColor(context, CGColorGetComponents( [color CGColor]));
//CGContextFillRect(context, rect);
//self.tintColor = color;
//图片填充
UIColor *color = [UIColor colorWithRed:46.0f/255.0f green:87.0f/255.0f blue:29.0f/255.0f alpha:1.0f];
UIImage *img = [UIImage imageNamed: @"button.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
self.tintColor = color;

}
@end

CustomNavgationBar.h

- (void)drawRect:(CGRect)rect;

无需引用,在有navbar的地方自动会改变


posted @ 2012-03-07 10:09 凡娃软件 阅读(141) 评论(1) 编辑

1.换颜色

    CGRect frame = CGRectMake(0, 0, 320, 47);

UIView *v = [[UIView alloc] initWithFrame:frame];

UIColor *c = [[UIColoralloc] initWithRed:0.4green:0.7blue:0.3alpha:1.0];

    v.backgroundColor = c;

[tabBarController.tabBarinsertSubview:v atIndex:0];


2.换图片

UIImageView* image = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@"button.png"]];

image.frame = CGRectMake(0, 0, 320,49);

[tabBarController.tabBarinsertSubview:image atIndex:0];


posted @ 2012-03-06 15:44 凡娃软件 阅读(202) 评论(0) 编辑
//匹配title
string reg="<td class=\"odd\">(?<Title>[\\s\\S]).*?)<td>";
//匹配tiitle与value
//string reg ="<td class=\"odd\">(?<Title>[\\s\\S]).*?)<td>([^<])<td class=\"value\">(?<Value>[\\s\\S].*?)</td>";
//以此类推



Regex r=new Regex(reg,RegexOptions.IgnoreCase | RegexOptions.Singleline);
MatchCollerction m=r.Matchs(str);
for(int i =0 ; i<m.Count;i++)
{
string title =m[i].Groups["Title"].Value;
}
posted @ 2012-03-06 12:00 凡娃软件 阅读(147) 评论(0) 编辑

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];

    self.window.backgroundColor = [UIColorwhiteColor];

    

    //生成各个视图控制器

    MedicalData* aa = [[MedicalDataalloc]init];

    UINavigationController *aaNav = [[UINavigationControlleralloc] initWithRootViewController:aa];

    HealthRecord* bb = [[HealthRecordalloc]init];

    UINavigationController *bbNav = [[UINavigationControlleralloc] initWithRootViewController:bb];

    KonwledgeBase* cc = [[KonwledgeBasealloc]init];

    UINavigationController *ccNav = [[UINavigationControlleralloc] initWithRootViewController:cc];

    CarePrescription* dd = [[CarePrescriptionalloc]init];

    UINavigationController *ddNav = [[UINavigationControlleralloc] initWithRootViewController:dd];

    //加入一个数组    

    NSArray* controllerArray = [[NSArray alloc]initWithObjects:aaNav,bbNav,ccNav,ddNav ,nil];

    //创建UITabBarController控制器  (定义在.h中,否在开启arc会自动释放掉,内存访问出错)

    tabBarController = [[UITabBarControlleralloc]init];

    //设置委托

    tabBarController.delegate = self;

    //设置UITabBarController控制器的viewControllers属性为我们之前生成的数组controllerArray

    tabBarController.viewControllers = controllerArray;

    //默认选择第1个视图选项卡(索引从0开始的)

    tabBarController.selectedIndex = 0;

    //设置TabBarItem的标题与图片//30 * 30

    [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:0] setTitle:@"体检数据"];  

    [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:0] setImage:[UIImageimageNamed:@"check_no.png"]];  

    [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:1] setTitle:@"健康档案"];

    [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:1] setImage:[UIImageimageNamed:@"check_yes.png"]];

    [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:2] setTitle:@"知识库"];

    [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:2] setImage:[UIImageimageNamed:@"ckb1.png"]];

    [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:3] setTitle:@"保健处方"];

    [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:3] setImage:[UIImageimageNamed:@"ckb2.png"]];

    //读取

    UIViewController* activeController = tabBarController.selectedViewController;

    if(activeController == aa){

        //

    }

    //tabBarControllerview作为子视图添加到window

    [self.windowaddSubview:tabBarController.view];

    [self.windowmakeKeyAndVisible];

    returnYES;

 

}

//切换事件

- (void)tabBarController:(UITabBar *)tb  didSelectViewController:(UIViewController *__strong)viewController

{

    NSLog(viewController.title);

    if([viewController.title isEqualToString:@"保健处方"])

    {

        [(UITabBarItem *)[tabBarController.tabBar.itemsobjectAtIndex:3] setBadgeValue:nil];

        //[(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:3] setBadgeValue:@"0"];

    }

}



posted @ 2012-03-06 09:56 凡娃软件 阅读(220) 评论(0) 编辑
摘要: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; //生成各个视图控制器 MedicalData* aa = [[MedicalData...阅读全文
posted @ 2012-03-05 15:45 凡娃软件 阅读(146) 评论(0) 编辑
摘要: //创建文件-(void)CreateFile:(NSString*)path fileName:(NSString*)filename{ //创建文件管理器 NSFileManager *fileManager = [NSFileManager defaultManager]; //更改到待操作的目录下 [fileManager changeCurrentDirectoryPath:[path stringByExpandingTildeInPath]]; //创建文件fileName文件名称,contents文件的内容,如果开始没有内容可以设置为nil,attributes文...阅读全文
posted @ 2012-03-05 10:56 凡娃软件 阅读(150) 评论(0) 编辑
摘要: /// <summary> /// 获得字符串中开始和结束字符串中间得值 /// </summary> /// <param name="str">字符串</param> /// <param name="s">开始</param> /// <param name="e">结束</param> /// <returns></returns> public static string GetValue(string s阅读全文
posted @ 2012-03-01 16:35 凡娃软件 阅读(149) 评论(0) 编辑