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 3 août 2015

class ChecklistViewController has no initialiser?

When I try to run my app it suddenly shows the error of class has no initialisers. Tell me whether their is any code problem or a variable declaration problems.Can anyone tells me the reason behind this error.

import UIKit
class ChecklistViewController: UITableViewController {



var row0item: ChecklistItem
var row1item: ChecklistItem
var row2item: ChecklistItem
var row3item: ChecklistItem
var row4item: ChecklistItem    


override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int

{
    return 5

}




override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

{
    let cell = tableView.dequeueReusableCellWithIdentifier("ChecklistItem")

    let label = cell!.viewWithTag(1000) as! UILabel



    if indexPath.row == 0 {

        label.text = row0item.text

    } else if indexPath.row == 1 {

        label.text = row1item.text

    } else if indexPath.row == 2 {

        label.text = row2item.text

    } else if indexPath.row == 3 {

        label.text = row3item.text

    } else if indexPath.row == 4 {

        label.text = row4item.text

    }

    configureCheckmarkForCell(cell!, indexPath: indexPath)

    return cell!
}





override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {


    if let cell = tableView.cellForRowAtIndexPath(indexPath) {


        if indexPath.row == 0 {
            row0item.checked = !row0item.checked

        } else if indexPath.row == 1 {
            row1item.checked = !row1item.checked

        } else if indexPath.row == 2 {
            row2item.checked = !row2item.checked

        } else if indexPath.row == 3 {
            row3item.checked = !row3item.checked
        } else if indexPath.row == 4 {
            row4item.checked = !row4item.checked

        }
        configureCheckmarkForCell(cell, indexPath: indexPath)

    }
    tableView.deselectRowAtIndexPath(indexPath, animated: true)

}








override func viewDidLoad() {
    super.viewDidLoad()

}





override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

}






func configureCheckmarkForCell(cell: UITableViewCell, indexPath: NSIndexPath) {

    var isChecked = false

    if indexPath.row == 0 {

    isChecked = row0item.checked
}
    else if indexPath.row == 1 {

    isChecked = row1item.checked
}
    else if indexPath.row == 2 {

    isChecked = row2item.checked
}
    else if indexPath.row == 3 {

    isChecked = row3item.checked
}
    else if indexPath.row == 4 {

    isChecked = row4item.checked }

    if isChecked {

    cell.accessoryType = .Checkmark

} else {

    cell.accessoryType = .None
    }
}

}

ios bluetooth core location etc

i have lots of questions, for which i did not get any answers from other firums. request your help for below doubts. it's ok to say "not possible"

My application pairs with a bluetooth device using obj c code. Everything works fine except that in between the wizard, system pops up an alert "do you want to pair with this device ? yes no". is there a way to silently pair the device without showing this alert ?

I have a requirement in my application that If for some reason my application malfunctions or crashes while running, user needs to be able to send diagonistic data to customer support. Is ther any third party application available which does this ?

in my application, some colors are industry standard, which should not change. but when i go to settings and do "switch color settings", my app's control colors change. how to make my app independent of color change in settings ?

Is it possible not to change my applications font size when the font size changes in settings of ios {in accessibility settings} ? Any hack solution would also do. I observed that the control which takes default font (when i dont specify any,) they change by accessibility font change, but others where i dynamically assign font family and sizes, font size does not change on accessibility font change.

at the worst case, is it possible to figure out inside my app through objc code that my phone is running in accessibility mode, so that i can display an alert ?

I am required to wake up my application when bluetooth pairing happensin ios. I see that the ios app can listen to external accessory, can any gentle soul please throw light to docs or sample codes or work arounds please ? wake up means while the app is in closed state, not in background running.

my initial research pointed towards below links.

Wake up ios app when a bluetooth device is near by How to wake up iOS app with bluetooth signal (BLE)

the last person's answer in both the posts indicate towards that it is possible. my doubt is for exactly what event i can wake up my application from closed state (i mean the user closed the app from background apps list ) ?

My further investigation revealed that in my app-info.plist, requiredbackgroundmodes is set to "App communicates using bluetooth"

Still the app does not receive any entry point when it is in stopped state upon bluetooth data arrival ! this is kinda baffling me.

should this go to didFinishLaunchingAppWithOptions ? should that be the entry point or something else ?

thanks

How can I save the videos that I'm recording?

I'm having trouble saving the videos that I'm recording. I can shoot, but I can not save them, just want to film and record videos in the library.

Can anyone help me?

 //My viewController

 import UIKit
 import MediaPlayer
 import MobileCoreServices
 import AVFoundation


 class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIGestureRecognizerDelegate {

let captureSession = AVCaptureSession()
var previewLayer : AVCaptureVideoPreviewLayer?
var captureDevice : AVCaptureDevice?

override func viewDidAppear(animated: Bool) {

    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {


        println("captureVideoPressed and camera available.")

        var imagePicker = UIImagePickerController()

        imagePicker.delegate = self
        imagePicker.sourceType = .Camera;
        imagePicker.mediaTypes = [kUTTypeMovie!]
        imagePicker.allowsEditing = false

        imagePicker.showsCameraControls = true


        self.presentViewController(imagePicker, animated: true, completion: nil)

    }

    else {
        println("Camera not available.")
    }
}

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


func imagePickerController(picker: UIImagePickerController!,  info: NSDictionary!) {

    let tempImage = info[UIImagePickerControllerMediaURL] as! NSURL!
    let pathString = tempImage.relativePath
    self.dismissViewControllerAnimated(true, completion: {})

    UISaveVideoAtPathToSavedPhotosAlbum(pathString, self, nil, nil)

}

}


  //My Library

  import UIKit;
  import MobileCoreServices

  class LibraryViewController: UIViewController, UINavigationControllerDelegate,UIImagePickerControllerDelegate {

@IBOutlet weak var myRecord: UIImageView!
@IBAction func aBottonPlay(sender: AnyObject) {
    var catchVideo = UIImagePickerController()
    catchVideo.delegate = self
    catchVideo.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
    catchVideo.mediaTypes = [kUTTypeMovie]
    self.presentViewController(catchVideo, animated: true, completion: nil)
}
override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
    myRecord.image = image
    self.dismissViewControllerAnimated(true, completion: nil)

}
}

Get facebook home feed in ios using Graph API v 2.4

I want to get all feed from facebook home with like and comment count in android and ios with Graph api version 2.4. Please help me asap.

thanks

How do universal shopping cart apps work? How the collect the data?

I'm doing some research for my app project which targets the "universal shopping cart" idea.

Apps like: Dote, Keep, Lyst..

I'm now looking into how these apps collect the data from the online shops? Do they just parse html into their own interfaces? Or request some sort of API access from these shops?

Sorry that this question is more conceptual than practical.

Unit test case for call back methods ios

I have a following method in my app for which I need to write unit test cases.
Can anyone suggest how can I test whether the success block or error block is called.

- (IBAction)loginButtonTapped:(id)sender

    {

          void (^SuccessBlock)(id, NSDictionary*) = ^(id response, NSDictionary* headers) {

            [self someMethod];

        };

        void (^ErrorBlock)(id, NSDictionary*, id) = ^(NSError* error, NSDictionary* headers, id response) {

         // some code

        };

            [ServiceClass deleteWebService:@“http://someurl"

                                               data:nil

                                   withSuccessBlock:SuccessBlock

                                     withErrorBlock:ErrorBlock];

    }

implement iAd video with MPMoviePlayerController with playPrerollAdWithCompletionHandler method

Well, I want to show a video ad just before starting a video in MPMoviePlayer

This is what I am doing:-

moviePlayer = [MPMoviePlayerController new];

moviePlayer.contentURL = [NSURL URLWithString:@"http://xyz/xyz.m3u8"];

[moviePlayer playPrerollAdWithCompletionHandler:^(NSError *error) {
        // Check if error is non-nil during development
        [moviePlayer play];
    }];
moviePlayer.view.frame=CGRectMake(0, 20, 300, self.view.frame.size.width);

And in Appdelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    [MPMoviePlayerController preparePrerollAds];
    return YES;
}


[self.view addSubview:moviePlayer.view];
[self.view layoutIfNeeded];

But what more should I do to show an ad video or how to configure the iAD to let the app understand which specific video to play as ad.

Currently the app is just playing this url "http://xyz/xyz.m3u8" video but not showing any ad.

Hear recording voice and background track at the same time with ios swift? [on hold]

I am able to record entire audio stream including background track when head phone not plugged into device . But when headphone plugged into device, i want to hear my voice and background track same time from headphone. But i hear only background track. How can i do that?

this is my recording code.

var audioRecorder:AVAudioRecorder!


func record(){

    var audioSession:AVAudioSession = AVAudioSession.sharedInstance()
    audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, error: nil)
    audioSession.setActive(true, error: nil)

    var documents: AnyObject = NSSearchPathForDirectoriesInDomains( NSSearchPathDirectory.DocumentDirectory,  NSSearchPathDomainMask.UserDomainMask, true)[0]
    var str =  documents.stringByAppendingPathComponent("recordTest.m4a")
    var url = NSURL.fileURLWithPath(str as String)

    var recordSettings = [AVFormatIDKey:kAudioFormatAppleIMA4,
        AVSampleRateKey:44100.0,
        AVNumberOfChannelsKey:2,AVEncoderBitRateKey:12800,
        AVLinearPCMBitDepthKey:16,
        AVEncoderAudioQualityKey:AVAudioQuality.Max.rawValue

    ]

    println("url : \(url)")
    var error: NSError?

    audioRecorder = AVAudioRecorder(URL:url, settings: recordSettings, error: &error)
    if let e = error {
        println(e.localizedDescription)
    } else {

        audioRecorder.record()
    }


}

SWRevealViewController and UITabbarController

In my app, I have added SWRevealViewController and UITabBarController, both are displayed from third view of app. When user successfully logged in then I have to display directly third view. The Tab bar display four tabs. User have option to move to other view from both side table and tabbar. I am facing issue when user is logged in and third view is loaded from AppDelegate then, user can't move to another view from side table. I get this error,

 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'

How can I make it happen. Please Help.

How to change the duration of a movement with count- Swift SpriteKit?

in my game there's a class for a "wall" that's moving to the left. I want to change the speed of it based on count i put in a touchesBegan class:

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {

    count++

}


func startMoving() {

        let moveLeft = SKAction.moveByX(-kDefaultXToMovePerSecond, y: 0, duration: 1 )

        let move = SKAction.moveByX(-kDefaultXToMovePerSecond, y: 0, duration: 0.5)

        if(count <= 10)
        {
            runAction(SKAction.repeatActionForever(moveLeft))
    }

    else
        {
        runAction(SKAction.repeatActionForever(move))
    }

but it's not working. can you help?

EXC_BREAKPOINT crash

I have this setup with a navigationcontroller:

SlideMenuController -> SchedulesViewController -> Schedule ViewController -> IntervalView

The schedulesviewcontroller is a list of all the schedules. The Schedule ViewController is the view with information about a schedule. IntervalView is the viewcontroller with a custom pickerview selecting a value.

I can load the SchedulesViewController, and then go to the ScheduleViewcontroller, and also from there to the IntervalView.

But when I try to hit the "Back" button, it works to the Schedule ViewController, but when I want to go back to the "SchedulesViewController", it crashes

[IntervalView respondsToSelector:]: message sent to deallocated instance 0x7fc78d320dc0

Thread 1 > EXC_BREAKPOINT(code=EXC_I386_BPT)

I don't know what code to show you, any help would be appreciated.

few view controllers are looking large when size class is enabled?

I am facing a very big problem with interface builder in Xcode .I am have used size class 'Width Regular,Height Compact' for iPhone in landscape mode.It was all working fine but suddenly it all messed up. I am facing two problems Whenever i change the size class to 'Width Regular,Height Compact'(iPhone Landscape) then i face these problems

  • ViewControllers in width looks very large.
  • Constraints are not updated properly.Whatever constraint i set it does look as it should be.

ScreenShot:Previous iPhone 5s preview ViewController: enter image description here

ScreenShot:Now iPhone 5s preview ViewController(too large) enter image description here

Please help me in getting the solution.

Google iOS API thumbnailURL: is not working iOS

I'm using Google API for my iOS app, and I have this code

    [shareBuilder setURLToShare:[NSURL URLWithString:@"http://ift.tt/1gDFMt0"]];

that works well and embeds the url to my post on Google+ as expected.

But another method with deep-link set doesn't:

    [shareBuilder setTitle:@"Uncollectible"
           description:@"Stay cool. Stay debtless."
          thumbnailURL:[NSURL URLWithString:@"http://ift.tt/1OKh1Wx"]];

My code is same as google example

id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];

  // This line will manually fill out the title, description, and thumbnail of the
  // item you're sharing.
  [shareBuilder setTitle:@"New 5k record!"
             description:@"I just ran 5000 meters in 26:16! That's a new record!"
            thumbnailURL:[NSURL URLWithString:@"http://ift.tt/1gDFORo"]];
  [shareBuilder setContentDeepLinkID:@"/races/sf/1234567"];
  [shareBuilder open];

Please advise. Thanks!

Parse Google Speech Kit JSON in iOS

I am having the following JSON response from Google speech API

    {
    "result": [

    ]
}{
    "result": [
        {
            "alternative": [
                {
                    "transcript": "testing 123"
                },
                {
                    "transcript": "listing 123"
                },
                {
                    "transcript": "casting 123"
                },
                {
                    "transcript": "fasting 123"
                },
                {
                    "transcript": "listing 1 2 3"
                },
                {
                    "transcript": "Justin 123"
                },
                {
                    "transcript": "listening 123"
                },
                {
                    "transcript": "listen 123"
                }
            ],
            "final": true
        }
    ],
    "result_index": 0
}

However I am having difficulties in parsing the JSON response. I have the following code

First approach: I get an empty result when I try to print

NSDictionary *results = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil];
NSDictionary *resultsDictionary = [[results objectForKey:@"result"] objectAtIndex:0];
    NSLog(@"result %@", resultsDictionary);

Second approach: getting the same empty result when I try to print

NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data
                                                     options:kNilOptions 
                                                       error:&error];

NSArray* ResultArray = [json objectForKey:@"result"];

NSLog(@"result: %@", ResultArray);

iOS pinterest integration authorization error

I want to integrate pinterest in iOS app. User should be able to pin image from app.

For it i have done setup according to below link. http://ift.tt/1OZrPAC

After login i m getting authorization error as shown in image.

Note :- I m testing app in simulator.

Can anybody help me to solve the issue?enter image description here

I really appreciate if there is any better solution which works.

Thanks

Should I set object to nill in Swift

I am reading someone's code. He set AVAudioPlayer to nil after user click a button to stop the audio from playing. I am wondering should we set object to nil after we don't need it anymore? Or should we set AVAudioPlayer to nil after we are trying to stop playing the audio?

Multi pin anotation show all default popup on then pin : iOS

map view

I have multi pin available, now i want show all popoup(Callout) default without any tap it is possible ?

Thank you in advance.

Tableview size change when i touch the screen

I have got 2 TableViews in the ViewController(1: tableView 2: tableview2) - the size of each one in the MainStoryBoard is 40, BUT in the code the size of each one is by its content size (for example: if i got 4 rows and each row is 22 so the tableview is 88).

When I run the app I see the size of the Tableviews as I want - by its content size, but when I click the screen to scroll down (I also got ScrollView) both tableviews become smaller to the size of the MainStoryBoard, which is 40.

What can I do to do not make the tableview smaller when I click it? Here is my code so far:

override func viewDidAppear(animated: Bool) {
    tableView.frame = CGRectMake(tableView.frame.origin.x, tableView.frame.origin.y, tableView.frame.size.width, tableView.contentSize.height)
    tableview2.frame = CGRectMake(tableview2.frame.origin.x, tableview2.frame.origin.y, tableview2.frame.size.width, tableview2.contentSize.height)
}
override func viewDidLayoutSubviews(){
        if tableView == tableview2 {
        tableView.frame = CGRectMake(tableView.frame.origin.x, tableView.frame.origin.y, tableView.frame.size.width, tableView.contentSize.height)
        tableview2.frame = CGRectMake(tableview2.frame.origin.x, tableview2.frame.origin.y, tableview2.frame.size.width, tableview2.contentSize.height)
        tableView.reloadData()
        tableview2.reloadData()
        } else {
            tableView.frame = CGRectMake(tableView.frame.origin.x, tableView.frame.origin.y, tableView.frame.size.width, tableView.contentSize.height)
            tableview2.frame = CGRectMake(tableview2.frame.origin.x, tableview2.frame.origin.y, tableview2.frame.size.width, tableview2.contentSize.height)
            tableView.reloadData()
            tableview2.reloadData()
        }
    }

Is there any Api to fetch IMDB data?

I am working on movie app ,i want to access IMDB Api ,but is there any Api of IMDB ? and how to use that Api in app

Bootstrap navbar not collapsing on iPhone

I am creating a site using Bootstrap, everything is working fine however when I go to view the site on my iPhone the navbar doesn't collapse. When viewing on my windows phone it works perfectly.

Here is the code for my header, can anyone see why this is happening?

<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
    <title><?php wp_title( ' | ',  true, 'right' ); ?></title>
    <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />
    <script src="http://ift.tt/1q8JMjW"></script>
    <link href='http://ift.tt/14vqKcZ' rel='stylesheet' type='text/css'>
    <meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" />
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
    <!-- Top logo and Search Bar -->
    <div class="row header navbar">
        <div class="container">
            <div class="col-md-3 logo-header hidden-xs hidden-sm">
                <a href="<?php echo home_url(); ?>/">
                    <img src="<?php echo  bloginfo('template_directory');?>/img/logo.jpg" alt="map consulting Logo" class="img-responsive">
                </a>
            </div>

            <div class="col-md-3 logo-header hidden-lg hidden-md">
                <a href="<?php echo home_url(); ?>/">
                    <img src="<?php echo  bloginfo('template_directory');?>/img/logo.jpg" alt="map consulting Logo" class="img-responsive img-center">
                </a>
            </div>

            <div class="clear"></div>

            <div class="col-md-3 pull-right hidden-xs hidden-sm"> 
                <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
                    <div class="input-group add-on">
                        <input type="text" class="form-control" placeholder="Search" name="s">
                        <div class="input-group-btn">
                            <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
                        </div>
                    </div>
                </form>
            </div> <!-- end of col md 3 -->
            <!-- Navigation for Phone and Tablet - hidden on large screens -->
            <div class="row hidden-lg hidden-md" id="mobileSearch" style="margin-bottom:10px;">
                <div class="col-xs-12"> 
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <div class="col-xs-12">
                        <?php wp_nav_menu( array( 'theme_location'    => 'main-menu',
                                           'depth'            => 1,
                                            'container_class' => 'collapse navbar-collapse',
                                            'menu_class'      => 'nav navbar-nav') ); ?>

                    </div>
                </div>
            </div>
            <!-- Navbar for large screens, hidden when on phone or tablet -->
            <div class="col-md-4 hidden-xs hidden-sm site-title pull-right">
                <div class="navbar-header">
                    <?php wp_nav_menu( array( 'theme_location'    => 'main-menu',
                                       'depth'            => 1,
                                        'container_class' => 'nav-large',
                                        'menu_class'      => 'nav navbar-nav') ); ?>
                </div> <!-- navbar collapse -->
            </div> <!-- navbar header -->
        </div> <!-- col md 4 -->
    </div> <!-- end of container -->