cocoa-touch,uiviewcontroller,uikitRelated issues-Collection of common programming errors


  • Brock Woolf
    objective-c cocoa cocoa-touch nsstring
    I have an NSString like so:@”200hello”or @”0 something”What I would like to be able to do is take the first occuring number in the NSString and convert it into an int. So that @”200hello” would become int = 200.and @”0 something” would become int = 0.

  • Darren Reely
    iphone cocoa cocoa-touch avfoundation
    First time asking a question here. I’m hoping the post is clear and sample code is formatted correctly.I’m experimenting with AVFoundation and time lapse photography.My intent is to grab every Nth frame from the video camera of an iOS device (my iPod touch, version 4) and write each of those frames out to a file to create a timelapse. I’m using AVCaptureVideoDataOutput, AVAssetWriter and AVAssetWriterInput.The problem is, if I use the CMSampleBufferRef passed to captureOutput:idOutputSampleBuffe

  • Rakhe Kara
    ios iphone objective-c cocoa-touch
    Actually this crash is not reproducing every time, even not frequently but we got this crash in our production app. I am not sure where is the problem. It is telling crash is happening in thread 4 in Environments class line number 38.Code:NSBundle* bundle = [NSBundle mainBundle];NSString* envsPListPath = [bundle pathForResource:@”Environment” ofType:@”plist”];Line 38: NSDictionary *environments = [[NSDictionary alloc] initWithContentsOfFile:envsPListPath];But according to exception type:00000020

  • Irfan
    ios cocoa-touch uiviewcontroller appdelegate uiviewanimationtransition
    It’s my first post on stackoverflow. I’m a iOS developer newbie and I’m not a native English speaker, so I will do my best to explain my problem. Problem:I have added two views to my AppDelegate window and I want to flip from one to the other using:UIView transitionFromView:toView:The first view (MainScreenView) has its own ViewController. On the MainScreenView .xib file I have a button with an action that calls the method “goShow” implemented in my AppDelegate. In that method I use UIView trans

  • stephen
    cocoa-touch network-programming
    I need to find the MAC address of the currently connected NSInputStream in a iPad/iPhone application. I have built a socket based on the Cocoa stream programming guide. I have done some digging. But, have only found things that do not work. For example, you can get a list of sockaddr pointers using:CFHostRef cfHostRef = CFHostCreateWithName(kCFAllocatorDefault, (CFStringRef) hostName); CFHostStartInfoResolution(cfHostRefInstance, kCFHostAddresses, NULL); Boolean resolved = false;CFArrayRef *

  • 0xSina
    ios objective-c cocoa-touch
    I need to do make some API calls in the background on the server that’s why I need the oauth token.Using ACAccountCredential’s oauthToken method, it returns null. My question is, it it possible to somehow get the oauth token?For example Instagram does this. They authenticate via Accounts framework and send the token to their servers where they do all the graph API calls.Thanks

  • HurkNburkS
    objective-c ios cocoa-touch nsarray
    I have a NSObject class in which I am sending a NSDictionary object too, the class object then sets all the entries in the NSDictionary to their native types that are variables in the NSObject class.I would then like to pass this NSObject class into its own NSMutableArray however my app is crashing when this happens.below is the code calling the NSObject Class and then trying to set it into a NSMutableArray.NSArray *filteredArray = parsedDataArrayOfDictionaries; //dictionary entries are currentl

  • poupou
    ios cocoa-touch linker monotouch static-libraries
    I have created a Cocoa Touch Static Library using Xcode 4 and I want to use it in a MonoTouch project. How do I proceed?Here is the content of my Static Library :MyClass.hMyClass.mI built using “Build For Archiving” after following THIS BLOG POST and I took the libMyLib.a it generated and added it to a new MonoTouch Binding Project.Then I replaced the content of libMyLib.linkwith.cs, because THIS BLOG POST said so. [assembly: LinkWith (“libMyLib.a”, LinkTarget.ArmV6 | LinkTarget.ArmV7 | LinkTar

  • Peter Hosey
    iphone cocoa-touch mode silent
    I would like to stop my application playing a sound if the user has switched the iPhone to silent mode. Where can I read that the phone is in silent mode? Is there some flag I can query? I noticed that some applications ignore the silent mode and some not, while I would have expected all apps to respect that silent is silent !! Any hints or input would be greatly appreciated. Thanks Al

  • morgancodes
    objective-c cocoa cocoa-touch json
    In java-land, there are a handful of useful libraries which will convert json strings to objects of matching type. The json libraries I’ve seen for cocoa simply create nested NSDictionaries and NSArrays. Is there a tool out there which will go the extra step of reconstituting whatever object type I want? So, for example, if I have a class called “Unicorn”, with a property “maneColor”, and I have json that looks like this:{“maneColor”:”silver” }I can automatically instantiate a Unicorn object wit

  • Irfan
    ios cocoa-touch uiviewcontroller appdelegate uiviewanimationtransition
    It’s my first post on stackoverflow. I’m a iOS developer newbie and I’m not a native English speaker, so I will do my best to explain my problem. Problem:I have added two views to my AppDelegate window and I want to flip from one to the other using:UIView transitionFromView:toView:The first view (MainScreenView) has its own ViewController. On the MainScreenView .xib file I have a button with an action that calls the method “goShow” implemented in my AppDelegate. In that method I use UIView trans

  • Ray White
    uiviewcontroller uinavigationcontroller uitableviewcontroller
    New to Xcode, new to Obj-C… not new to programming. I have an iPhone storyboard hierarchy like the one below, and am expecting the UITableViewController to automatically open the UIViewController when I tap on a table item. It doesn’t.UINavigationController- UITableViewController (derived class)- UIViewController (derived class)I assumed that because I dragged a link named “Manual Segue, push” from the UITableViewController to the UIViewController in the IB that an automatic connection was m

  • Alex Stone
    objective-c delegates uiviewcontroller self
    I have 2 UIViewControllers in a UITabBar and would like to create a facade for one of my UIViewControllers, and am running into issues when trying to do this://within the 2nd view controller, that has not been displayed yet: -(void)startApp {locationManager.delegate = self;[locationManager startUpdatingLocation];}I’m trying//within the first view controller:[delegate startApp]What does “self” refer to in the example above? If I set a breakpoint, I see that the callback within the 2nd view contro

  • OpenLearner
    iphone objective-c ipad uiviewcontroller uinavigationcontroller
    For a controller that is pushed by a nav controller, if in its desired init method you create the details of the pushed controller’s view, my understanding is that if the view is removed later because it is offscreen (due to low memory, for example), you may never see it again since the init is only called once when loading the view controller, and subsequent pushes may show nothing. It would seem a better place for this view setup is in the viewDidLoad or viewWillAppear, that way it will be rec

  • Dave
    ipad uiviewcontroller ipad-splitview uiinterfaceorientation
    I am presenting MFMailComposeViewController as modal from a view controller (lets call it xyz) added to nav stack. When user clicks on cancel button, the MFMailComposeViewController is dismissed. This works fine when xyz is added to nav stack in portrait/landscape mode and the device orientation doesn’t change until after cancel is clicked. present modal – alloc init MFMailComposeViewController on a button tap[self.navigationController presentModalViewController:mailController animated:NO];dismi

  • César Bustíos
    iphone ios xcode uiviewcontroller ios5
    All I need is to view a UIView controller in same storyboard file manually with code. I use storyboard to make all forms and connections. My application starts in navigation controller, which provides me access to UIView (LoginViewController) and then it goes to tab bar controller, which provides 4 UIViews. According to every UIView I have .h and .m files. I know about segue method, it is simple, but I need manual method. Maybe I am doing something wrong.I was trying to use this method for pushi

  • BoyGeneral
    iphone ipad uiviewcontroller orientation
    I’m developing a program based iPad. I created new modal UIViewController as formsheet mode not full screen. And to resize the view, i used following codes. …MyController* controller = [[MyController alloc] init];controller.modalPresentationStyle = UIModalPresentationFormSheet;[self presentModalViewController : controller animated: YES];UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;if ( UIInterfaceOrientationIsPortrait(orientation) )controller.view

  • Michael Nana
    ios objective-c uiviewcontroller
    I’m learning iOS programming right now and I started off building an app. So right now I’m working on registering a user which sends the details of the user to a server and then responds with a json array. The result can be true or false. Now what I want to do is if the result is true, open up a new view controller. I searched online and on stackoverflow and I did thisif([operation boolValue] == 0){NSLog(@”Account Registered: %s”,”Yes”);[self.navigationController pushViewController:MainViewContr

  • spd
    uiviewcontroller rotation ios5
    I am developing an iPhone application. In this application, UIViewController (vc1) presents another UIViewController (vc2). vc1 supports both Portrait and Landscape orientations; vc2 supports only Portrait orientation.When vc2 is presented, it asks vc1: shouldAutorotateToInterfaceOrientation: and this returns YES 2.In iOS5(Beta 7) willRotateToInterfaceOrientation:, didRotateFromInterfaceOrientation: are not getting called for this sequence. But, this works fine in iOS4. Is this a bug in iOS5?Tha

  • Michael Rowe
    uiviewcontroller methods uitabview
    I am working on my first simple tabview controller app. The first tab is a setup tab, and I just had a tester provide an unexpected use case. In order to address this use case, I need to execute when the user is leaving the view and before I load the next one. Running code in the next view is too late.What method is called from the current viewController at the point the user selects the TabView Controller to switch views?I’ve tried using viewWillDisappear as the point to execute my code, but

  • Nate
    ios uiwebview uiscrollview uikit
    The QuestionDoes anyone know of technical reasons for avoiding web views inside scroll views on iOS (assuming you’re willing to disable scrolling inside the web views themselves)?If you look at the Apple docs for UIWebView, they state:Important: You should not embed UIWebView or UITableView objects inUIScrollView objects. If you do so, unexpected behavior can resultbecause touch events for the two objects can be mixed up and wronglyhandled.My Educated GuessIt looks like maybe they’re warning you

  • mvds

  • Thanks
    iphone cocoa-touch xcode uikit provisioning
    Yesterday I testet a lot on my device. Suddenly I get this error message when I hit Build & Go in Xcode. First, it asks me if it’s ok to sign with my key. I click yes, and then that error message appears. My iPod is connected as usual, iTunes starts automatically and I close that to prevent interruptions.I tried restarting Xcode. Doesn’t help. My Apple Dev Enrollment is brand new. Any idea what the problem might be?Edit: In Window > Organizer I can see this message: Your mobile device has en

  • Anand
    ios objective-c uikit
    I have one UIbutton. I want it to move from point A to point B. While going, that button have to do one full 360′ rotation.After some event, I want that UIButton to come back to its position, this time rotating in the reverse direction.I wrote this code, but it didnt work. I’m seeing the button rotate in unexpected ways. What am I missing here?To move:[UIView animateWithDuration:0.3 animations:^{CGAffineTransform rotate360AntiClockWise = CGAffineTransformMakeRotation(M_PI_2);CGRect initialFrame

  • istan
    iphone ios uikit
    I think I’m probably missing something obvious here? I have a UITextView that I animate it’s y position when a user takes a certain action viaCGRect frame = self.messageTextView.frame;[UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];frame.origin.y += 120; self.messageTextView.frame = frame;[UIView commitAnimations];That works great, but when my user taps a button to launch an imagePicker that animated UITextView s

  • Fabrizio
    iphone ipad uikit
    do anyone have experience with TableView inside a custom TableCell ?I had a try and the TableView in the TableCell looks like that can’t respond to user inputs (ie scrolling).Before going any further I would like to know if I am wasting my time !Does anyone have seen something like that around ? Any reference would be helpful.Thanks

  • bjtitus
    iphone objective-c uikit uipageviewcontroller
    I am trying to disable the pan gesture recognizer for a UIPageViewController.On iOS 5 I can loop through them and disable them.for (UIGestureRecognizer* recognizer in self.pageViewController.gestureRecognizers) {if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]]) {recognizer.enabled = NO;} }On iOS 6 using UIPageViewControllerTransitionStyleScroll there are no gesture recognizers returned by the Page View Controller.ClarificationThis can be boiled down to:self.pageViewController.gestur

  • Jim Dovey
    ios cocoa-touch uitableview uitableviewcell uikit
    I’m using a custom drawn UITableViewCell, including the same for the cell’s accessoryView. My setup for the accessoryView happens by the way of something like this:UIImage *accessoryImage = [UIImage imageNamed:@”accessoryDisclosure.png”]; UIImageView *accImageView = [[UIImageView alloc] initWithImage:accessoryImage]; accImageView.userInteractionEnabled = YES; [accImageView setFrame:CGRectMake(0, 0, 28.0, 28.0)]; self.accessoryView = accImageView; [accImageView release];Also when the cell is init

  • Boon
    iphone uikit
    In my app, I would like to resize the tableview’s height when it’s in edit mode vs when it’s not (in order to make room for editing controls below the table view)How should this be done?

  • Emily
    ios uiview uikit
    such as the code:view.opaque = YES;andview.backgroundColor = [UIColor clearColor];any one who can explain something about this?EDIT:as the document shows:Declare Views as Opaque Whenever PossibleUIKit uses the opaque property of each view to determine whether the view can optimize compositing operations. Setting the value of this property to YES for a custom view tells UIKit that it does not need to render any content behind your view. Less rendering can lead to increased performance for your dr

Web site is in building