Affichage des articles dont le libellé est Active questions tagged iphone - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged iphone - Stack Overflow. Afficher tous les articles

lundi 27 avril 2015

UIImage size in a tableView Cell


I have an image 1024x1024 and I want resize this image to fit into a tableView Cell. I have used this lines of code:

+ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize {

   //New size is the size of the cell for me
   UIGraphicsBeginImageContext(newSize);
   [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
   UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();
   NSData *imageData = UIImagePNGRepresentation(img);
   UIImage *imgFinal=[UIImage imageWithData:imageData];

   return imgFinal;

}

The problem is, when I visualize this image on the screen of Iphone6 or Iphone6+ the image appear blurred and a little bit pixelated. Can you help me?


Upload an image after 64-bit encoding


I want to upload an image on a server. I encode to 64-bit then I post. I am using this code:

NSURL *url=[[NSURL alloc] initWithString:@"http://ift.tt/1EBLi9u"];

NSMutableURLRequest *req=[[NSMutableURLRequest alloc] initWithURL:url];
[req setHTTPMethod:@"POST"];
// [req setValue:@"multipart/form-data; boundary=*****" forHTTPHeaderField:@"Content-Type"];

NSMutableData *postBody=[NSMutableData data];
NSString *boundary=@"*****";


[postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"uploadedfile\"; filename=\"test.png\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
NSString *this=[pickedImageData base64EncodedString];

[postBody appendData: [this dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[req setHTTPBody:postBody];


NSHTTPURLResponse *response=nil;
        NSError *error=[[NSError alloc] init];

NSData *responseData;
    responseData=[NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
    NSLog(@"%@",responseData);
    if(responseData&&[responseData length])
    {

        NSDictionary *dictionary=[NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
        NSLog(@"%@",dictionary);
    }
    else
    {
        NSLog(@"hello");
    }


How can I send a picture about 100kb in size to a PubNub channel in iOS SDK?


What I was doing, converting the whole image to base64 string and sending it as a message. But message sending failed each time. I got maximum payload size is 32 KB for a single PubNub message here. If I compress the image and so that my message size is less than 32 KB, will it be delivered? Is there any other API available from PubNub SDK to upload or streaming a file/image to a channel?


get view controller stack from storyboard


I try to get view-controllers array of Navigation Controller.It will returns blank array as shown below:

   UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil]; 
UINavigationController *nav1 = [mystoryboard instantiateViewControllerWithIdentifier:@"nav1"];
 NSLog(@"%@",nav1.viewControllers);

but this displays empty array even though it has view controller.

Thanks in advance


iphone restarts when I try to run my app


Hey I can't put any code into here because there is too much. but when I put my game onto my phone it crashes the phone and it restarts itself.
I have an iPhone 4 running 7.1.2 Xcode 6.

I'm using sprite kit with objective c. could there be anything that I have used that is only meant for iOS 8. I don't have a crash report as I don't have the developer licence.


How to connect iPhone 5s to SmartFace?


I've just installed smartface version 4.3.0

I connected my iPhone 5S to the laptop using USB cable.

I launched Smartface App Studio, clicked on Device Emulator from toolbar. Clicked on Yes button when User Account dialog appears. Progress Dialog appears, it says: "Searchign for devices... Devices found: Simon's iPhone

Keep calm ;) You need to download Smartface in action from app store and then please try again.

Same issue again? Please refer to Troubleshooting document!"

I downloaded the app on my iPhone and launched, what haven't I done?


Only I can sign into the app I have moulded in Objective C xcode. What are the possible causes of this?


I am using the latest version of FBSDKv4.0.1 in my app but only I can sign in to the app. When somebody else is trying to sign in error is obtained, why?

if ([FBSDKAccessToken currentAccessToken])
    {
        // User is logged in, do work such as go to next view controller.
        self.loginButton.readPermissions = @[@"public_profile", @"email",     @"user_friends"];
    ProgressHUD *HUD=[[ProgressHUD alloc]init];
    [HUD showTextOnlyAndHideForChat:@"Fetching details" parentView:self.view];
}

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    if (error)
    {
        // Process error
        NSLog(@"fbsdk error log");
        ProgressHUD *HUD=[[ProgressHUD alloc]init];
        [HUD showTextOnlyAndHide:@"Invalid credentials" parentView:self.view];
    }
    else if (result.isCancelled)
    {
        // Handle cancellations
        NSLog(@"fbsdk Handle cancellations");
        ProgressHUD *HUD=[[ProgressHUD alloc]init];
        [HUD showTextOnlyAndHide:@"Activity cancelled by user" parentView:self.view];
    }
    else
    {
        // If you ask for multiple permissions at once, you
        // should check if specific permissions missing
        if ([result.grantedPermissions containsObject:@"email"])
        {

            [[NSUserDefaults standardUserDefaults] setObject:[[FBSDKAccessToken currentAccessToken] tokenString] forKey:@"fbaccesstoken"];

           NSLog(@"fbaccesstoken %@",[[FBSDKAccessToken currentAccessToken] tokenString]);

//                NSDictionary *dictionaryJSON = [NSJSONSerialization JSONObjectWithData:result options:NSJSONReadingMutableLeaves error:&error];
//NSLog(@"DICTIONARY==%@\nresult===%@",dictionaryJSON,result);
            NSLog(@"fbsdk if log");
            // Do work

            ProgressHUD *HUD=[[ProgressHUD alloc]init];
            [HUD hideHudProgress];
            //------------test
            if ([FBSDKAccessToken currentAccessToken]) {
//                    ProgressHUD *HUD=[[ProgressHUD alloc]init];
//                    [HUD showHudProgressWithText:@"Fetching user information.." withView:self.view];

                [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
                 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                     if (!error) {

#success statements#
}

This is the error log I am getting.

Error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo=0x7ac62bd0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x79678040> { URL: http://ift.tt/1EbKJQy? token=(access-token-value)                                                                               { status code: 401, headers {
    Allow = GET;
    Connection = "Keep-Alive";
    "Content-Language" = en;
    "Content-Type" = "application/json";
    Date = "Sat, 25 Apr 2015 08:09:45 GMT";
    "Keep-Alive" = "timeout=5, max=100";
    Server = Apache;
    "Transfer-Encoding" = Identity;
    Vary = "Accept,Accept-Language,Cookie";
    "Www-Authenticate" = Token;
} }, NSErrorFailingURLKey=http://ift.tt/1EbKJQy?

NSLocalizedDescription=Request failed: unauthorized (401), com.alamofire.serialization.response.error.data=<7b226465 7461696c 223a2022 41757468 656e7469 63617469 6f6e2063 72656465 6e746961 6c732077 65726520 6e6f7420 70726f76 69646564 2e227d>}

Can anybody please tell me if i made a mistake in this code snippet? Or is it the bug in the latest FBSDK?


In sales and trends, why does proceeds divided by sales only = 66% and not 70%?


Recently Apple started including "sales" in iTunes Connect Sales and Trends which denotes the total revenue your app has made before Apple takes its 30% cut, while "proceeds" is what you made after the cut is subtracted.

Why is it when I take my lifetime proceeds and divide it by my lifetime sales, I only get 66-67% instead of 70%? What is happening to this other 3-4%?


Send MMS using Twilio in ios


I want to send MMS using Twilio. I am request one twilio url which is work fine on SMS but not MMS and I want to know what should change so i am sending MMS using Twilio in iOS. Here is my code.

NSLog(@"Sending request.");

// Common constants
NSString *kTwilioSID =@"Twilio SID";
NSString *kTwilioSecret =@"Twilio Secret";
NSString *kFromNumber = @"From Phone Number";
NSString *kToNumber = @"To Phone number";
NSString *kMessage=@"Hello This is Pintu vasani";

// Build request
NSString *urlString = [NSString stringWithFormat:@"https://%@:%@@api.twilio.com/2010-04-01/Accounts/%@/SMS/Messages", kTwilioSID, kTwilioSecret, kTwilioSID];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];

// Set up the body  MediaUrl
NSString *bodyString = [NSString stringWithFormat:@"From=%@&To=%@&Body=%@", kFromNumber, kToNumber, kMessage];
NSData *data = [bodyString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:data];
NSError *error;
NSURLResponse *response;
NSData *receivedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

// Handle the received data
if (error) {
    NSLog(@"Error: %@", error);
} else {
    NSString *receivedString = [[NSString alloc]initWithData:receivedData encoding:NSUTF8StringEncoding];
    NSLog(@"Request sent. %@", receivedString);
}


Displaying AdMob and/or iAd when switching tabs using shared banners on ios


I have an app with a UITabBarController containing 5 tabs, where each tab is a UIViewController with a UITableView embedded in. I am bringing iAds and AdMobs to my app which will be removed using IAPs. This is a universal iPhone and iPad app.

At first, I implemented just the iAds with the use of Shared Banners and the AppDelegate and it worked really well. Now, before releasing, I am going to also bring AdMobs as a fallback incase any iAds don't load. I have set it up in the same way as the iAd.

Implementing the actual AdMob is not a problem in the same way, but I am facing issues when changing tabs.

Issue

If an iAd loads and I move from the first tab to the second tab, it continues to show that iAd. If an AdMob loads and I move from the first tab to the second tab, the AdMob disappears until it reloads again.

Here's some code:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    NSLog(@"VIEW WILL APPEAR");
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"IAPSuccessful"])
    {
        NSLog(@"View will appear and the IAP is not Successful");
        [self displayiAdsOrNot];
    }
    else
    {
        NSLog(@"View will appear and the IAP IS Successful");
        self.adBanner.hidden = YES;
        self.adMobBannerView.hidden = YES;
    }
}

- (void)displayiAdsOrNot
{
    NSLog(@"Display iAds or Not");

    self.adMobBannerView.hidden = YES;
    self.adBanner = [[self appdelegate] adBanners];
    self.adBanner.delegate = self;

    if (IDIOM == IPAD)
    {
        NSLog(@"***This is the iPad****");
        [self.adBanner setFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height-80, 320, 50)];
        [self.adBanner setTranslatesAutoresizingMaskIntoConstraints:NO];

        [self.view addSubview:self.adBanner];
        NSLayoutConstraint *myConstraint =[NSLayoutConstraint
                                           constraintWithItem:self.adBanner
                                           attribute:NSLayoutAttributeLeading
                                           relatedBy:NSLayoutRelationEqual
                                           toItem:self.view
                                           attribute:NSLayoutAttributeLeading
                                           multiplier:1.0
                                           constant:0];

        [self.view addConstraint:myConstraint];



        myConstraint =[NSLayoutConstraint constraintWithItem:self.adBanner
                                                   attribute:NSLayoutAttributeTrailing
                                                   relatedBy:NSLayoutRelationEqual
                                                      toItem:self.view
                                                   attribute:NSLayoutAttributeTrailing
                                                  multiplier:1
                                                    constant:0];

        [self.view addConstraint:myConstraint];

        myConstraint =[NSLayoutConstraint constraintWithItem:self.adBanner
                                                   attribute:NSLayoutAttributeBottom
                                                   relatedBy:NSLayoutRelationEqual
                                                      toItem:self.view
                                                   attribute:NSLayoutAttributeBottom
                                                  multiplier:1
                                                    constant:0];

        [self.view addConstraint:myConstraint];

    }
    else
    {
        NSLog(@"*** THIS IS THE IPHONE ***");
        [self.adBanner setFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height-98, 320, 50)];
        [self.view addSubview:self.adBanner];
    }

}

Here are the delegate methods:

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    NSLog(@"bannerViewDidLoadAd gets called");

    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"IAPSuccessful"])
    {
        NSLog(@"bannerViewDidLoadAd gets called and the IAP is not successful, so we hide the AdMob and show the iAd");
        self.adMobBannerView.hidden = YES;
        self.adBanner.hidden = NO;
    }
    else
    {
        NSLog(@"bannerViewDidLoadAd gets called and the IAP IS Successful so we hide the AdMob and iAd");
        self.adMobBannerView.hidden = YES;
        self.adBanner.hidden = YES;
    }


}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"The didFailToReceiveAdWithError is called and it is unable to show ads in Timeline. Error: %@ %@", [error localizedDescription], [error domain]);
    self.adBanner.hidden = true; 
    [self displayAdMobBannerOrNot];
}

- (void)displayAdMobBannerOrNot
{
    NSLog(@"DisplayAdMobBannerOrNot is called");
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"IAPSuccessful"])
    {
        NSLog(@"The DisplayAdMonBannerOrNot is called and the IAP is not Successful");
        self.adMobBannerView.hidden = NO;
        self.adMobBannerView = [[self appdelegate] adMobBanners];
        self.adMobBannerView.rootViewController = self;
        self.adMobBannerView.delegate = self;

        self.adMobBannerView.adUnitID = @"ca-app-pub-394025609333333333335716";

        if (IDIOM == IPAD)
        {
            NSLog(@"The DisplayAdMobBannerOrNot is called and we are using an iPad");
            [self.adMobBannerView setFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height-80, 320, 50)];
            [self.adMobBannerView setTranslatesAutoresizingMaskIntoConstraints:NO];

            [self.view addSubview:self.adMobBannerView];
            NSLayoutConstraint *myConstraint =[NSLayoutConstraint
                                               constraintWithItem:self.adMobBannerView
                                               attribute:NSLayoutAttributeLeading
                                               relatedBy:NSLayoutRelationEqual
                                               toItem:self.view
                                               attribute:NSLayoutAttributeLeading
                                               multiplier:1.0
                                               constant:0];

            [self.view addConstraint:myConstraint];

            myConstraint =[NSLayoutConstraint constraintWithItem:self.adMobBannerView
                                                       attribute:NSLayoutAttributeTrailing
                                                       relatedBy:NSLayoutRelationEqual
                                                          toItem:self.view
                                                       attribute:NSLayoutAttributeTrailing
                                                      multiplier:1
                                                        constant:0];

            [self.view addConstraint:myConstraint];

            myConstraint =[NSLayoutConstraint constraintWithItem:self.adMobBannerView
                                                       attribute:NSLayoutAttributeBottom
                                                       relatedBy:NSLayoutRelationEqual
                                                          toItem:self.view
                                                       attribute:NSLayoutAttributeBottom
                                                      multiplier:1
                                                        constant:0];

            [self.view addConstraint:myConstraint];

        }
        else
        {
            NSLog(@"The DisplayAdMobBannerOrNot is called and we are using an iPhone");
            [self.adMobBannerView setFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height-98, 414, 50)];

            [self.view addSubview:self.adMobBannerView];

                GADRequest *request = [GADRequest request];
                request.testDevices = @[ @"151111111111ffb836f4d823ac" ];
                [self.adMobBannerView loadRequest:request];
        }
    }
    else
    {
        NSLog(@"The DisplayAdMobBannerOrNot is called and the IAP IS Successful so we'll just hide the iAd and the adMobBanner");
        self.adBanner.hidden = YES;
        self.adMobBannerView.hidden = YES;
    }
}

So, when the viewWillAppear gets called (every time I come back to this UIViewController), I am checking if the IAPSuccessful bool is true. If it's not, I load up the displayiAdsOrNot method. If that fails, it's delegate will get called which calls the displayAdMobBannerOrNot.

Now, I completely understand why, when I have an AdMob displaying and I move from one view to another, it removes the AdMob because when I come back, the viewWillAppear loads up the sharedBanner for the iAd and not the AdMob.

With that in mind, I'm not really sure what I need to do. I want to ensure the AdMob is loading the sharedBanner every time it's loaded. So I put the sharedBanner code from the displayAdMobBannerOrNot into the displayiAdOrNot and it didn't change the behaviour, because it's not calling the functionality to actually place the ad (displayAdMobBannerOrNot).

As a test, in the viewWillAppear, when the IAPSuccessful is false, I called [self bannerView:self.adBanner didFailToReceiveAdWithError:nil]; instead of anything else and that worked. When I moved from tab one to two two, it kept the AdMob in display. However, that's of course not productional code. I'm just not able to see this clearly.

Any guidance on this would really be appreciated.


How to AutoLayout the buttons in uiview controller in iphone?


I have size of 4 inch and i have added 4 icons in 3 different rows of all equal size 60x60. I can have a proper view in iphone 4s,5,5s but not in iphone 6 and 6 plus. So how can i apply auto layout to it and make the icons look bigger and of same ratio in iphone 6 and 6 plus. Can this be made without any coding?

Like this enter image description here

This buttons should change its size in iphone 6 and 6 plus i.e. it should get bigger and proper aligned. Can it is possible without coding?


UIViewController in iOS app launch screen


Is it possible to add a view controller to launch screen in iOS ? if yes How could i do that ?

I have dragged a UIViewController to the LaunchScreen.xib file its run correctly, but when i changed the class for the view controller in the LaunchScreen.xib from "identity inspector" from UIViewController to myLaunchScreenViewControllerName i faced this error

Illegal Configuration : Launch screen may not use instance of myLaunchScreenViewControllerName

if you can help me I will be thankful for you thanking in advance :)


Notification in iPhone banner


When we send a push notification to app it automatically added to banner and show to user. But I want to show message in banner from app to user.

Is it possible, If yes how can do this?


iOS: UITableView cells gets mixed up while scrolling


I am facing one issue regarding UITableView cells get mixed up while scrolling, specially for images.

I am not sure why this is going one.
I have change the patter for displaying then also its get mixed up.
Below is my code.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"FriendsCell";
    FriendsTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FriendsTableCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }

    return cell;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    FriendsTableCell *simpleTableCell = (FriendsTableCell *)cell;

    _model = [_contentArray objectAtIndex:indexPath.row];

    simpleTableCell.nameLabel.text = _model.fullname;

    if(_friendsSegmentControl.selectedSegmentIndex == 0) {

        simpleTableCell.followButton.hidden = NO;
        simpleTableCell.removeButton.hidden = NO;
        simpleTableCell.unBlockButton.hidden = YES;
        simpleTableCell.ignoreRequest_btn.hidden = YES;
        simpleTableCell.rejectRequest_btn.hidden = YES;
        simpleTableCell.acceptRequest_btn.hidden = YES;

        simpleTableCell.removeButton.tag = indexPath.row;
        [simpleTableCell.removeButton addTarget:self action:@selector(deleteFriend_btn:) forControlEvents:UIControlEventTouchUpInside];

        simpleTableCell.followButton.tag = indexPath.row;

        if([_model.isfollowed isEqualToString:@"YES"]) {
            [simpleTableCell.followButton setImage:[UIImage imageNamed:@"follow_yellow.png"] forState:UIControlStateNormal];
            [simpleTableCell.followButton addTarget:self action:@selector(unfollowFriend_btn:) forControlEvents:UIControlEventTouchUpInside];
        }
        else {
            [simpleTableCell.followButton setImage:[UIImage imageNamed:@"follow_white.png"] forState:UIControlStateNormal];
            [simpleTableCell.followButton addTarget:self action:@selector(followFriend_btn:) forControlEvents:UIControlEventTouchUpInside];
        }
    }

    NSString *escapedString = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,(__bridge CFStringRef) _model.prof_pic,NULL,(CFStringRef)@"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8));

    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
    dispatch_async(queue, ^(void) {

        NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://ift.tt/1QyVOl3",escapedString]]];
        UIImage *image = [UIImage imageWithData:imageData];
        dispatch_async(dispatch_get_main_queue(), ^{
            simpleTableCell.profileImageView.image = image;
        });
    });

}


NSDateComponents.quater is returning 0 instead of valid quater count


NSDateComponents.quater is returning 0 instead of valid quater count.

I googled and it is said it is a bug for apple found in 2012. However, now it is 2015 and iOS 8.3, bug still exists.

for example:

unitFlags = NSQuarterCalendarUnit;

(lldb) po firstDate
2009-12-31 16:00:00 +0000

(lldb) po lastDate
2013-09-30 16:00:00 +0000

(lldb) po [gregorian components:unitFlags fromDate:firstDate toDate:lastDate options:0];
<NSDateComponents: 0x170158b50>
    Quarter: 0


How to create custom UIView according to uploaded image in iOS?


I want to create custom UIView in my iOS app and my custom UIView like this kind of image type .enter image description here


Has anything changed with custom UITableView prototype cells constraints since iOS 8.3?


I have recently installed iOS 8.3 on my iPhone (I had iOS 8.1 before).

I also updated the iOS SDK from iOS 8.1 to iOS 8.3.

Since I updated it some custom prototype cells I had seem to be misplaced.

Has anything changed from iOS 8.1 to iOS 8.3 regarding the way constraints are handled?


dimanche 26 avril 2015

Size of UIScrollView and Size of Images


I have created this scrollview that loads the images dynamically. However I cannot get the images to cover the screen (should adapt to iPhone/iPad) one and one. And the height of the images is also corrupt (see attached image)

What am I doing wrong?

Image

enter image description here

Source to load images:

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

        // create image
        NSString *imageName = [NSString stringWithFormat: imageArray[i], i+1];
        UIImage *image = [UIImage imageNamed:imageName];
        UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

        // put image on correct position
        CGRect rect = imageView.frame;
        rect.origin.x = currentX + self.scrollView.frame.size.width/2;
        imageView.frame = rect;

        // update currentX
        currentX += imageView.frame.size.width + self.scrollView.frame.size.width;

        [self.scrollView addSubview:imageView];
        [imageView release];
    }

    self.scrollView.contentSize = CGSizeMake(currentX, self.view.frame.size.height);

    self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
    [self.view addSubview:scrollView];
    [self.scrollView release];


Read verification code automatically and access for Login in App in iOS


I am creating one App and it has verification phone number required functionality which allow user to enter into App. We send sms to the Users through the gateway and we need to read verification code directly from the SMS without typing code into App. But don't know how to read verification code automatic from the SMS and access in my App.I have gone thorugh the searches for this but could not find any path to move ahead. Is it allow in iOS and if Yes, can anyone tell me what to do to achieve it. Thanks.


Get total number of annotations of visible cluster/s in mkmapview


Can anyone help me with MKMapViews. I am using the FBAnnotations/FBClustering.

My issue is, for example, lets say I have 20 annotations and is clustered in to 4. I have 2 clusters visible in the map, cluster A with 3 annotations and cluster B with 4 annotations.

I want the total of cluster A and B be the title of the view controller (in my case it should be 7).
Instead of getting 7 I keep getting the total number of annotations in my map.

I uploaded an image, please click here.
Here's what i've got so far:
This is the method in my MKMapView view controller:

- (void)mapViewWithJobsDisplayed:(NSDictionary *)jobsDictionary andUserLocation:(CLLocation *)location andUserCoordinates:(CLLocationCoordinate2D)locationCoordinates
{   
    if(locationCoordinates.latitude == 0.0f || locationCoordinates.longitude==0.0f)
    { 
    }
    else
    {
        ar = [jobsDictionary objectForKey:@"sub_slots"];

        //Save location
        userLocation = location;
        userLocationCoordinates = locationCoordinates;

        // Initiate cluster array
        clusterArray = [[NSMutableArray alloc] initWithCapacity:ar.count];

        for (int i = 0; i < ar.count; i++) {
            NSDictionary *jobPin = [ar objectAtIndex:i];
            latitude = [[jobPin objectForKey:@"sub_slots"] objectForKey:@"latitude"];
            longitude = [[jobPin objectForKey:@"sub_slots"] objectForKey:@"longitude"];
            companyName = [[jobPin objectForKey:@"sub_slots"] objectForKey:@"company_name"];
            companyAddress = [[jobPin objectForKey:@"sub_slots"] objectForKey:@"address"];

            CLLocationCoordinate2D coordinate;
            coordinate.latitude = [latitude doubleValue];
            coordinate.longitude = [longitude doubleValue];

            if([latitude doubleValue] == 0.0f || [longitude doubleValue]==0.0f)
            {
            }
            else
            {
                MyLocation *annotation = [[MyLocation alloc] initWithName:companyName address:companyAddress coordinate:coordinate];
                [annotation setTagNumber:i];
                [self addAnnotation:annotation];
                [clusterArray addObject:annotation]; 
            }
        }

        //Create clustering manager
        clusteringManager = [[FBClusteringManager alloc] initWithAnnotations:clusterArray];
        clusteringManager.delegate = self;
        [self refreshMapView];
    }
}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    MKAnnotationView *av = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"JobsPins"];

    UIImage *backgroundImage = [UIImage imageNamed:@"pinMap"];
    if ([annotation isKindOfClass:[FBAnnotationCluster class]])
    {
        FBAnnotationCluster *cluster = (FBAnnotationCluster *)annotation;
        cluster.title = [NSString stringWithFormat:@"%lu", (unsigned long)cluster.annotations.count];
        av.canShowCallout = YES;
        UIImage *frontImage = [self drawTextWithStroke:cluster.title andImage:backgroundImage];
        av.image = [self placeImage:frontImage onImage:backgroundImage];
        // Check zoom level and show accessory button
        NSUInteger zoomLevel = [self zoomLevelForMapRect:mapView.visibleMapRect withMapViewSizeInPixels:mapView.bounds.size];

        if (zoomLevel > 1) {
            av.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        }

        return av;
    }

    if ([annotation isKindOfClass:[MyLocation class]])
    {
        av.canShowCallout = YES;
        UIImage *frontImage = [self drawTextWithStroke:@"1" andImage:backgroundImage];
        av.image = [self placeImage:frontImage onImage:backgroundImage];
        av.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

        return av;
    }

    return nil;
}