Monday, 30 November 2015

How To Set Floating Pont in TableViewHeaderView Ios/Iphone

CGFloat dummyViewHeight = 40;
UIView *dummyView = [[UIView alloc]

initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width,

dummyViewHeight)];
self.tableView.tableHeaderView = dummyView;
self.tableView.contentInset = UIEdgeInsetsMake(-dummyViewHeight, 0, 0, 0);

Saturday, 28 November 2015

how to Use Url Image Reguler Expressation Ios/iphone

 
    NSString *searchedString = [[arr objectAtIndex: indexPath.row]
 objectForKey: @"description"];
   
    NSRange rangeOfString = NSMakeRange(0, [searchedString length]);
    //NSLog(@"searchedString: %@", searchedString);
   
    NSString *pattern = @"src=\"([^\"]+)\"";
    NSError* error = nil;
    NSTextCheckingResult* match;
    NSRegularExpression* regex = [NSRegularExpression
regularExpressionWithPattern:pattern options:0 error:&error];
    NSArray *matchs = [regex matchesInString:searchedString
options:0 range:rangeOfString];
    for (match in matchs) {
        NSLog(@"url: %@", [searchedString substringWithRange:
[match rangeAtIndex:1]]);
      
    }

Friday, 27 November 2015

Work Selected Row By default and Check Mark In UITableView Ios/Iphone

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
[self.tableView selectRowAtIndexPath:indexPath
                            animated:YES
                      scrollPosition:UITableViewScrollPositionNone];
[self tableView:self.tableView didSelectRowAtIndexPath:indexPath];





 ==> Selected Checkmark row



- (UITableViewCell *)tableView:(UITableView *)tableView

cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:

 CellIdentifier];

    if(cell == nil )
    {
        cell =[[[UITableViewCell alloc] initWithStyle:

 UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
    if ([indexPath compare:self.lastIndexPath] == NSOrderedSame)
    {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else
    {
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    return cell;
}

// UITableView Delegate Method
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:

(NSIndexPath *)indexPath
{
    self.lastIndexPath = indexPath;

    [tableView reloadData];
}

Thursday, 26 November 2015

How To Hide Navigation Bar Button ios Iphone

UIBarButtonItem *oldButton = self.navigationItem.rightBarButtonItem;
[oldButton retain];
self.navigationItem.rightBarButtonItem = nil;

//... later
self.navigationItem.rightBarButtonItem = oldButton;

Wednesday, 25 November 2015

How To Udr NSLocal Country name Ios/iphone

NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]

 autorelease];

NSString *country = [usLocale displayNameForKey: NSLocaleCountryCode value:

 countryCode];

Tuesday, 24 November 2015

Work With NSNotification Center Ios/Iphone

=> Here User Dealloct Whiitch Used Notification:
- (void) dealloc
{
   
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

- (id) init
{
    self = [super init];
    if (!self) return nil;

==> add observe Notification default center:-   

    [[NSNotificationCenter defaultCenter] addObserver:self
        selector:@selector(receiveTestNotification:)
        name:@"TestNotification"
        object:nil];

    return self;
}

=> have Received Notification:-



 - (void) receiveTestNotification:(NSNotification *) notification
{
    // [notification name] should always be @"TestNotification"
    // unless you use this method for observation of other notifications
    // as well.

    if ([[notification name] isEqualToString:@"TestNotification"])
        NSLog (@"Successfully received the test notification!");
}

@end



- (void) someMethod
{

    // All instances of TestClass will be notified
    [[NSNotificationCenter defaultCenter]
        postNotificationName:@"TestNotification"
        object:self];

}
=================================================================

NSDictionary *userInfo = [NSDictionary dictionaryWithObject:myObject

forKey:@"someKey"];
    [[NSNotificationCenter defaultCenter] postNotificationName:

 @"TestNotification" object:nil userInfo:userInfo]; 



- (void) receiveTestNotification:(NSNotification *) notification

    NSDictionary *userInfo = notification.userInfo;
    MyObject *myObject = [userInfo objectForKey:@"someKey"];
}

Saturday, 21 November 2015

How to Use Perfom Selector Ios/Iphone

dispatch_async(dispatch_get_main_queue(), ^{
    [self doSomething:1 b:2 c:3 d:4 e:5];
});



[ invocationObject performSelectorOnMainThread: @selector( invoke )

   withObject: nil, waitUntilDone: NO ];



- (void)threadMain:(id)data {
    NSAutoreleasePool *pool = [NSAutoreleasePool new];

    NSRunLoop *runloop = [NSRunLoop currentRunLoop];
    [runloop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];

    while (isAlive) { // '
        [runloop runMode:NSDefaultRunLoopMode beforeDate:

[NSDate distantFuture]];
    }

    [pool release];
}

How To Chnage Navigationbar Color Ios/iphone

==> change the back button chevron color for a specific navigation contro:
self.navigationController.navigationBar.tintColor =

 [UIColor whiteColor];
==> TO change Whole Navigation bar color:-
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];


UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
backButton.title = @"go back - now!";
backButton.tintColor =

 [UIColor colorWithRed:0.1 green:0.5 blue:0.7 alpha:1.0];
self.navigationItem.backBarButtonItem = backButton;

Friday, 20 November 2015

How to pass index another UIController ios/iphone


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

 if ([[segue identifier] isEqualToString:@"showDetail"]) {
 NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
 NSString *selectedNation =[[[self.tableView cellForRowAtIndexPath:

indexPath] textLabel] text];
[[segue destinationViewController] setSelectedNation:selectedNation];
 [[segue destinationViewController] setDelegate:self];
    }

Wednesday, 18 November 2015

Work With Asset Libery ios 5 in Ios/Iphone

LAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSString *photoName;
NSString *photoUrl;

 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
    void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) =

 ^(ALAsset *result, NSUInteger index, BOOL *stop)
    {
        if(result != NULL)
        {
            NSArray *arrKeys = [[result valueForProperty:

 ALAssetPropertyURLs]allKeys];            
            if([[result valueForProperty:ALAssetPropertyType]

 isEqualToString:ALAssetTypePhoto])
            {
                if([[UIDevice currentDevice] systemVersion]>=5.0))
                {
                    photoName = [[result defaultRepresentation]UTI];

                }
                else
                {
                    photoName = [[result defaultRepresentation]filename];

                }
                //Your code here
                photoUrl = [[result valueForProperty:ALAssetPropertyURLs]

 objectForKey:[arrKeys objectAtIndex:0]];

            }
        }
    };

    void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) =

 ^(ALAssetsGroup *group, BOOL *stop)
    {
        if(group != nil)
        {
            [group enumerateAssetsUsingBlock:assetEnumerator];
        }
    };
    [library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:

assetGroupEnumerator failureBlock:^(NSError *error){
        NSLog(@"%@",error);
    }];

    [pool release];

Tuesday, 17 November 2015

How to populate OTP from user's sms Inbox to application directly in ios/iphone

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)

 url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if (!url) {
    UIApplication * yourapplication =[UIApplication sharedApplication];
    NSString *outputpath =@"appname://data/";
    NSURL *url =[NSURL URLWithString:outputpath];
    [yourapplication openURL:url];
    return NO;
}

NSUserDefaults *defaultString =[NSUserDefaults standardUserDefaults];
NSString * commonString =[url absoluteString];
if (commonString.length<=15) {
    //
}
else
{
    [defaultString setObject:commonString forKey:@"urlString"];
}
     //send info to the screen you need and can navigate
 return YES;
}

How To Know UIButton Pressed Ios/Iphone

property (nonatomic, strong)  UIButton *btn1;
@property (nonatomic, strong) UIButton *btn2;
@property (nonatomic, strong) UIButton *btn3;

btn1.tag=1;
btn2.tag=2;
btn3.tag=3;

[btn1 addTarget:self action:@selector(difficultyButtonPressed:)

forControlEvents:UIControlEventTouchUpInside];

[btn2 addTarget:self action:@selector(difficultyButtonPressed:)

forControlEvents:UIControlEventTouchUpInside];

[btn3 addTarget:self action:@selector(difficultyButtonPressed:)

forControlEvents:UIControlEventTouchUpInside];

- (IBAction)difficultyButtonPressed:(UIButton*)sender
{
 NSLog(@"Button tag is %d",sender.tag);

     // you can use if else condition using sender.tag  like

      if(sender.tag==1)//first button related identifire
      {
           [self performSegueWithIdentifier:

          @"mainGameTurnGuess_FirstButtonIdentirier" sender:sender];
      }
      else if(sender.tag==2)//second button related identifier
      {
            [self performSegueWithIdentifier:

            @"mainGameTurnGuess_secondButtonIdentirier" sender:sender];
      }
      else   //Third button related identifier
      {
            [self performSegueWithIdentifier:

         @"mainGameTurnGuess_ThirdButtonIdentirier" sender:sender];
      }



- (IBAction)difficultyButtonPressed:(id)sender {
    UIButton *button = (UIButton *)sender;
    NSLog(@"Button tag is %d",button.tag);
}

Tuesday, 10 November 2015

How To Use UIAlertView With Login Password TextField Ios/Iphone

 UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Your_Title" message:@"Your_message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[av setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

// Alert style customization
[[av textFieldAtIndex:1] setSecureTextEntry:NO];
[[av textFieldAtIndex:0] setPlaceholder:@"First_Placeholder"];
[[av textFieldAtIndex:1] setPlaceholder:@"Second_Placeholder"];
[av show];


=> Here Used Delegate file :-

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
     NSLog(@"1 %@", [alertView textFieldAtIndex:0].text);
     NSLog(@"2 %@", [alertView textFieldAtIndex:1].text);
}