Tuesday, 24 January 2012

urldemo 5

//For the hexa code to UIColor 
- (UIColor *) colorWithHexString: (NSString *) hex 

    NSString *cString = [[hex stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; 
   
    // String should be 6 or 8 characters 
    if ([cString length] < 6) return [UIColor grayColor]; 
   
    // strip 0X if it appears 
    if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2]; 
   
    if ([cString length] != 6) return  [UIColor grayColor]; 
   
    // Separate into r, g, b substrings 
    NSRange range; 
    range.location = 0; 
    range.length = 2; 
    NSString *rString = [cString substringWithRange:range]; 
   
    range.location = 2; 
    NSString *gString = [cString substringWithRange:range]; 
   
    range.location = 4; 
    NSString *bString = [cString substringWithRange:range]; 
   
    // Scan values 
    unsigned int r, g, b; 
    [[NSScanner scannerWithString:rString] scanHexInt:&r]; 
    [[NSScanner scannerWithString:gString] scanHexInt:&g]; 
    [[NSScanner scannerWithString:bString] scanHexInt:&b]; 
   
    return [UIColor colorWithRed:((float) r / 255.0f) 
                           green:((float) g / 255.0f) 
                            blue:((float) b / 255.0f) 
                           alpha:1.0f]; 
}
how to use it
[self.view setBackgroundColor: [self colorWithHexString:@"Ff0000"]];


//For the slider to unlock example for slider
    altosdesign.com/iphonesdk/SlideToCancel.zip
    http://www.altosdesign.com/iphonesdk/SlideToCancel.zip

//For the pop to specific view in iPhone
[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: 1] animated: YES];

//For the custom image slider

 UIImage *minImage = [UIImage imageNamed:@"grey_track.png"];
    UIImage *maxImage = [UIImage imageNamed:@"white_track.png"];
    UIImage *tumbImage= [UIImage imageNamed:@"metal_screw.png"];
   
    minImage=[minImage stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
    maxImage=[maxImage stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
   
    // Setup the FX slider
    [maxPriceSlider setMinimumTrackImage:minImage forState:UIControlStateNormal];
    [maxPriceSlider setMaximumTrackImage:maxImage forState:UIControlStateNormal];
    [maxPriceSlider setThumbImage:tumbImage forState:UIControlStateNormal];


//For the sectioned TableView
http://www.mobisoftinfotech.com/blog/iphone/iphone-uitableview-tutorial-grouped-table/
/*<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
 <key>Photo</key>
 <string>mobile.png</string>
 <key>Mobile Phones</key>
 <array>
 <string>GSM Phones</string>
 <string>Dual Sim Phones</string>
 <string>CDMA Phones</string>
 </array>
 <key>Smart Phones</key>
 <array>
 <string>IOS Phones</string>
 <string>Android OS Phones</string>
 <string>Blackberry Phones</string>
 <string>Symbian OS Phones</string>
 <string>Tablet Phones</string>
 <string>Windows OS Phones</string>
 <string>Bada OS Phones</string>
 </array>

 <key>Mobile Accessories</key>
 <array>
 <string>Screen Protectors</string>
 <string>Memory Card</string>
 <string>HeadPhones</string>
 <string>CaseMate</string>       
 <string>Bluetooth Devices</string>       
 </array>

 <key>Landline Phones</key>
 <array>
 <string>Landline Phones</string>
 </array>

 </dict>
 </plist>
 */

-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden=NO;
        self.title=@"Sub Category";
    appDel=(AppDelegate *)[[UIApplication sharedApplication]delegate];
    NSLog(@"indexValue %@",indexValue);
    NSString *getPlist=[[NSBundle mainBundle] pathForResource:indexValue ofType:@"plist"];
    NSLog(@"%@",getPlist);
    plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:getPlist];
    NSLog(@"%@",plistDict);
   
   
    NSString *getPhoto=[plistDict valueForKey:@"Photo"];
    UIImageView *bgImgView=[[UIImageView alloc] initWithFrame:CGRectMake(subCatTableView.frame.origin.x, subCatTableView.frame.origin.y, subCatTableView.frame.size.width, subCatTableView.frame.size.height)];
    bgImgView.image=[UIImage imageNamed:getPhoto];
    bgImgView.alpha=0.5;
    subCatTableView.backgroundView=bgImgView;
    [plistDict removeObjectForKey:@"Photo"];
   
   
   
    sectionArray=[[NSMutableArray alloc] init];

    sectionArray =[[[plistDict allKeys]sortedArrayUsingSelector:@selector(compare:)] mutableCopy];
   
    NSLog(@"%@",sectionArray);
    subCatArray=[[NSMutableArray alloc] init];
   

   
}
#pragma mark Table Methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return [sectionArray count];
}

- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
    return [sectionArray objectAtIndex:section];
}

- (NSInteger)tableView:(UITableView *)table
 numberOfRowsInSection:(NSInteger)section {
    NSArray *listData =[plistDict objectForKey:
                        [sectionArray objectAtIndex:section]];
    return [listData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
   
    NSArray *listData =[plistDict objectForKey:
                        [sectionArray objectAtIndex:[indexPath section]]];
   
    UITableViewCell * cell = [tableView
                              dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
   
    if(cell == nil) {
       
        cell = [[[UITableViewCell alloc]
                 initWithStyle:UITableViewCellStyleDefault
                 reuseIdentifier:SimpleTableIdentifier] autorelease];
         cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        /*cell = [[[UITableViewCell alloc]
         initWithStyle:UITableViewCellStyleSubtitle
         reuseIdentifier:SimpleTableIdentifier] autorelease];
         */
    }
    cell.selectionStyle=UITableViewCellSelectionStyleGray;
    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listData objectAtIndex:row];
   
    return cell;
}

- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSArray *listData =[plistDict objectForKey:
                        [sectionArray objectAtIndex:[indexPath section]]];
    NSUInteger row = [indexPath row];
    NSString *rowValue = [listData objectAtIndex:row];
   
    NSString *message = [[NSString alloc] initWithFormat:rowValue];
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"You selected"
                          message:message delegate:nil
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:nil];
    [alert show];
    [alert release];
    [message release];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
   
}

//For the view like the easy out and view like small to big
http://stackoverflow.com/questions/8175367/iphone-uiview-animation-resize-in-like-disappear-in-water-and-comes-back-floatin
CGRect originalFrame = scheduleView.frame;
   
    [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
        CGRect frame = scheduleView.frame;
        frame.origin = scheduleView.center;
        frame.size = CGSizeMake( 0, 0 );
        scheduleView.frame = frame;
    } completion:^(BOOL finished) {
        // Do something with the view
       
        [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
           scheduleView.frame = originalFrame;
        } completion:^(BOOL finished) {
            return;
        }];
       
        return;
    }];


//For the paypal library
https://www.x.com/developers/paypal/documentation-tools/sdk

//For the multiselection of row
- (void)viewDidLoad {
    [super viewDidLoad];
    self.arForTable=[NSArray arrayWithObjects:@"Object-One",@"Object-Two",@"Object-Three",@"Object-Four",@"Object-Five", nil];
    self.arForIPs=[NSMutableArray array];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.arForTable count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    if([self.arForIPs containsObject:indexPath]){
        [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
    } else {
        [cell setAccessoryType:UITableViewCellAccessoryNone];
    }
    cell.textLabel.text=[self.arForTable objectAtIndex:indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if([self.arForIPs containsObject:indexPath]){
        [self.arForIPs removeObject:indexPath];
    } else {
        [self.arForIPs addObject:indexPath];
    }
    [tableView reloadData];
}




//For the different source code
http://projectswithlove.com/projects/

http://osx.hyperjeff.net/Reference/CocoaArticles?cat=52


//For the MPMediaItemArtwork
https://github.com/erica/MPMediaItem-Properties

//For the different demos
http://www.vellios.com/downloads/

//Soap parsing Demos
http://www.devx.com/wireless/Article/43209
http://iphonebyradix.blogspot.com/2011/04/working-with-webservices.html
http://www.icodeblog.com/2008/11/03/iphone-programming-tutorial-intro-to-soap-web-services/

//To generate the random charter unto limit
 NSString *chars = @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    NSMutableString *randomString = [NSMutableString stringWithCapacity: string_length];
    for (int i=0; i<string_length; i++)
    {
        [randomString appendFormat:@"%C", [chars characterAtIndex: arc4random()%[chars length]]];
    }


//For the writing to the xml file
NSString *fromNumber;
    NSString *toNumber;
    NSString *msg;
   
   
    NSString *tempString = @"<?xml version=""1.0"" encoding=""UTF-8""?>";
    NSString *strXmlNode = [[NSString alloc] initWithFormat:@"%@<TwilioResponse><SMSMessage><Sid>AP38503af035184c6a8b9cb9b7c70fb2b4</Sid><DateCreated>Wed, 18 Aug 2010 20:01:40 +0000</DateCreated><DateUpdated>Wed, 18 Aug 2010 20:01:40 +0000</DateUpdated><DateSent/><AccountSid>AC696f8df0c9ca45cfb59b073ad5e3ee02</AccountSid>\n""<To>+919904523387</To>\n"
        "<From>+%@</From>\n"
        "<Body>%@</Body>\n"
        "<Status>queued</Status>\n"
        "<Direction>outbound-api</Direction>\n"
        "<ApiVersion>2010-04-01</ApiVersion>\n"
        "<Price/>\n"
        "<Uri>/2010-04-01/Accounts/AP38503af035184c6a8b9cb9b7c70fb2b4/SMS/Messages/AC696f8df0c9ca45cfb59b073ad5e3ee02</Uri>\n"
        "</SMSMessage>\n"
        "</TwilioResponse>",fromNumber,toNumber,msg];
   
/*    NSData *data = [[NSString stringWithString:strXmlNode] dataUsingEncoding:NSUTF8StringEncoding];
   
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   
    NSString *documentsDirectory = [paths objectAtIndex:0];
   
    NSString *dataFilePath = [[documentsDirectory stringByAppendingPathComponent:@"Message.xml"] retain];
   
    [data writeToFile: dataFilePath atomically:YES]; */




No comments:

Post a Comment