Thursday, August 25, 2011

Dyanamic adding and removing buttons


#### button Adding

- (IBAction)whisky:(id)sender {




if(j<21) {

CGRect rect = CGRectMake(100,20,70,20);
lbl1= [[[UILabel alloc] initWithFrame:rect] autorelease];
NSString *intString = [NSString stringWithFormat:@"%d", j-10];
[lbl1 setText:intString]; lbl1.tag=99; [self.view addSubview:lbl1];
button3 = [UIButton buttonWithType:UIButtonTypeCustom];
[button3 addTarget:self action:@selector(ratingAction2:)forControlEvents:UIControlEventTouchUpInside];
[button3 setBackgroundImage:[UIImage imageNamed:@"scanbutton1.png"] forState:UIControlStateNormal]; button3.tag = j;
button3.backgroundColor = [UIColor blueColor];
button3.frame = CGRectMake(120, width1, 35, 35);
[self.view addSubview:button3]; width1 = width1 -38; j++;
}
}


############### button delete based on tag ###########



- (IBAction)delWhis:(id)sender { if(j>1)
{
j--;

int f;
f=j;

[[self.view viewWithTag:f] removeFromSuperview];

//int b = button3.tag/10;




{
NSLog(@" whisky ration is %d",f);
width1 = width1 +38;


}


}


}

Dynamic button and Event on them ( Retro)

- (IBAction)Can:(id)sender {

i++;

UIButton *button2;
//view did load

// for( i= 1;i<=5;i++)

{
button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[button2 addTarget:self action:@selector(ratingAction:)forControlEvents:UIControlEventTouchUpInside];
[button2 setBackgroundImage:[UIImage imageNamed:@"scanbutton1.png"] forState:UIControlStateNormal];
button2.tag = i;
button2.backgroundColor = [UIColor clearColor];
button2.frame = CGRectMake(20, width, 35, 35);
[self.view addSubview:button2];
width = width -38;
}



NSLog(@" i am can ");
// [self dismissModalViewControllerAnimated:YES];




}



-(void)ratingAction:(id*)sender
{

if ([sender isKindOfClass:[UIButton class]]) {


UIButton *temp=(UIButton*)sender;





if ([temp tag]==1 || [temp tag]==3 || [temp tag]==6 || [temp tag]==7 ) {

[temp setBackgroundColor:[UIColor redColor]];

}
}
}

Tuesday, August 23, 2011

Android Installation

Download Andriod SDK and Eclispse


2) Launch Eclipse


3) go to help -> install new software

4) enter this url


‪http : //dl-ssl.google.com/Android/eclipse/‬

5)and configure


6) then create a new project (Others) and select google api and then launch first app



Monday, August 15, 2011

MD5 in Xcode

import --> #import CommonCrypto/CommonDigest.h
then make a Class Utility


in .h


#import Foundation/Foundation.h

#import CommonCrypto/CommonDigest.h
@interface Utilities : NSObject {

}

//generates md5 hash from a string
+ (NSString *) returnMD5Hash:(NSString*)concat;

@end
##############################################################
in .m





#import "Utilities.h"
@implementation Utilities

//generate md5 hash from string
+ (NSString *) returnMD5Hash:(NSString*)concat {
const char *concat_str = [concat UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(concat_str, strlen(concat_str), result);
NSMutableString *hash = [NSMutableString string];
for (int i = 0; i < 16; i++)
[hash appendFormat:@"%02X", result[i]];
return [hash lowercaseString];

}

@end










#######################

in the main Class





NSString *myMD5String = [Utilities returnMD5Hash:@"test"];
NSLog(@" myMD5String ----------------------- %@",myMD5String);




And Its Done , Happy Coding :)




FEEDJIT Live