My app works perfectly on the simulator, but not on my iPad. I have a UILabel (created programatically) that displays an NSAttributedString. The label itself appears, but the string won't display on the device (but works on simulator). I have confirmed through testing that the label will display a normal NSString, and I have also confirmed that if I create a UILabel with Interface Builder I can display attributed text in it.
The UILabel itself is a property of my view controller, declared with (strong, nonatomic).
I'm fairly new at this, so dumb mistakes are possible. Any idea what could be wrong?
Thanks.
I found the answer. It had nothing to do with UILabel or NSAttributedString. Turns out that the text files were not properly loading on my device, because the name of the file was capitalized in the bundle but not capitalized in my code. It worked on simulator because (it turns out) simulator does not care about file capitalization, but my device does. Once I got the text file to load, everything displayed as expected.
Related
I try to build a simple app based on the UISplitViewController template from Xcode 6 for universal apps (with Storyboard and CoreData/NSFetchedResultsController). This app should also provide a search bar for the MasterViewController. Unfortunately, Xcode 6 provides no InterfaceBuilder element for the UISearchBar/UISearchController combo (only the depreciated UISearchBar/UISearchDisplayController).
In the iOS Developer library, Apple provides the "Table Search with UISearchController" example, but this is not based on the UISplitViewController and supports only iPhone.
My problem is, that I'm not able to show the detail view on the correct ViewController under all circumstances. I tried to transfer the approach from the Apple example project to the UISplitViewController template. In this, one is encouraged to show the search results in a separate UITableViewController subclass (ResultsTableViewController) and use this as the searchResultsController of the UISearchController. I was not able to create a scene in InterfaceBuilder for this setup so I had to add these manually in code.
The problems begin when I click on a table cell of the ResultsTableViewController. This vc is not part of the scene in InterfaceBuilde and I don't know how to add it to the SplitViewController setting correctly. The biggest problem is the weird behavoir of the iPhone 6 Plus and the UISplitViewController. In portrait mode it behaves like an iPhone and doesn't seem to have a SplitViewController and only uses a NavigationController to which I push my DetailViewController. In landscape mode it behaves like an iPad with SplitViewController were I have to get the second ViewController of the SplitViewController childControllers and push the DetailViewController on this one.
Now it happens, when I start in portrait mode and switch to landscape mode that the DetailViewController is all gone, showing gray space where the DetailVC should be. It seems, when going to portrait mode, the DetailViewController gets kicked from the SplitViewController (or the SplitViewController gets kicked at all in favor for the iPhones NavigationController setup). When switching back to landscape the SplitViewController is initialized again but without proper initialization of the DetailViewController.
Is there any template or suggestion on how to correctly implement search capabilities on a universal UISplitViewController?
Cheers
Björn
I am having a very strange problem.
I have a tableView, which when the cell is clicked it segues to the next VC, sending the data from that cell with it via prepareForSegue function. From the next VC I then segue from there to another VC (again passing the data needed via prepareForSegue). The final VC is a chat style VC, so it contains a scrollView and a textView, the three VCs look like so:
In the chatViewController I have set up a Parse backend so it queries the data and then places inside the scrollView like so:
The problem I am having is that the keyboard does not pop open. I know the code is CORRECT! As it pops open when I make the chatViewController the initial VC. it just doesn't work when it is segued to from multiple VC.
Does anybody have any ideas on this or ever had any problems with segueing into a scrollViewController. I've tried everything I can think off.
Thanks in advance.
If you're on ios simulator, the software keyboard may be turned off. For actual emulation you may try a ios phone instead of simulator.
If you wanna appear the soft-keypad in simulator try following
solution
iOS Simulator -> Hardware -> Keyboard
Uncheck "Connect Hardware Keyboard"
Mine was checked because I was using my mac keyboard, but if you make sure it is unchecked the iPhone keyboard will always come up.
solution is actually copied from here
Hi all for some reason in my iOS project on the latest Xcode6 the keyboard is refusing to appear anymore when I click inside a input textfield or textview.
I did have one of my fields dismissing the keyboard via
.h
IBOutlet UITextField *textField; {
}
- (IBAction)dismissKeyboard:(id)sender;
.m
- (IBAction)dismissKeyboard:(id)sender {
[textField resignFirstResponder];
}
but even when I delete this code, even tried deleting the view controller files & storyboard and have tried dragging the input textfield/view onto my other view controllers/views and still it refuses to appear no matter where I put it!
Also tried doing a clean, restarting Xcode and the Mac itself.
At the moment I don't even have any custom code in my controller file .m or h.
Apart from restarting the project I'm not sure how I get this default behaviour of the keyboard appearing when clicking inside an input back!
The only thing I have been doing in my other storyboard view controllers is experimenting with constraints/autolayout.
Scratching my head, apart from starting a new project file I'm not sure what to do, any help would be great
Boss, Go to Simulator-> select Hardware -> go to keyboard -> and then do toggle keyboard.It works.Cheers
I'm quite new to iOS Programming. I've done Objective-C for about a year, and now I want to start making apps for the iPhone. I think I'm missing out on something really simple, though. What I've done is this:
First I created a new Single View Application with TestApp as a product name. I enabled Use Storyboards, Use Automatic Reference Counting and Include Unit Tests. After creating the project, I dragged a UIButton onto the View in the storyboard file.
Note that I didn't write a single line of code. I launched my app in the iPhone Simulator and pressed the button, but it's not responding. I know I didn't assign an action to the press of the button, but the gradient of the button isn't changing, as I know it should. The User Interaction Enabled properties of both my view and my button were enabled.
Recently, I've created a few apps in Xcode that worked just fine, but I didn't use storyboards in those projects. Thus, I'm guessing there's something extra to do when using storyboards of which I'm just unaware. I'm using Xcode 4.5 and the iPhone 6.0 Simulator.
I wrote NSLog(#"View was loaded."); statement in the viewDidLoad method of my ViewController to make sure this view controller was actually loaded. (I know my button wouldn't show up if it was the wrong view controller, but I did this just to make sure.)
I also wrote a changeTitle: method in my ViewController to change the title of my button to New Title after it was pressed, just in case the button worked but its gradient just wouldn't respond to a tap. I linked this IBAction to my button, but it wasn't called.
In my ViewController, I created an IBOutlet of a UIButton which I connected to my button. In the viewDidLoad method of my ViewController, I changed the title of my button to New Title, this actually worked. The title of my button changed to this new title when launching my app in the iOS Simulator. The button itself still wasn't responding, though.
As a last try, I also wrote [button setEnabled:YES]; in my ViewController's viewDidLoad method, but this didn't help. My button still doesn't respond to any tap. What am I missing out on?
This is weird. I had an issue with my printer, so I restarted my computer. After this, this issue was suddenly solved as well (just like my printer issue). I'm not sure how this could have affected anything, but I'm glad it works again!
Ran into the same issue.
Apparently Content Reseting the Simulator worked for me
Very strange this..
I wrote an app that has about 3 different view controllers for each view in the tab bar. I called applicationDidEnterBackground: in each of the view controllers to save all the data in that specific view after the home button is tapped. This runs flawlessly on the iPad simulator, but for some reason, it crashed after trying to edit the data on the iPhone simulator. I thought this is probably an issue with putting the applicationDidEnterBackground: in the view controller, but if that was the issue, then wouldn't it crash on the iPad simulator as well?
I know that I should put applicationDidEnterBackground in the app delegate, but my method looks sort of like this:
- (void)applicationDidEnterBackground:(NSNotification *)notification {
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:firstField.text];
[array addObject:secondField.text];
[array writeToFile:[self dataFilePath] atomically:YES];
}
If I put this in the App Delegate, of course it doesn't recognize firstField or secondField because I did not declare it in header file or synthesize it or anything. If I were to declare everything in the App Delegate, then the outlets in my nib file will fail because each of the File's Owner's class is one of those specific view controllers.
Is the placement of applicationDidEnterBackground: not even my issue since it runs fine on the iPad simulator?
Also, it used to run fine on the iPhone simulator as well. I changed the Image View's background on all of the nibs, then this started happening. I rechecked all my outlets and actions and they match up fine.
EDIT: I fixed it. Turns out I had an extra field that I decided to add to the iPad's nib, but not the iPhone's. I though it would be fine, not the case though. That explains all the weirdness that was going on. I deleted the field in the iPad's nib and everything is A Okay. Phillipe, thank you so much for your help and offer to look it over for me, that is incredibly generous.
I fixed it. Turns out I had an extra field that I decided to add to the iPad's nib, but not the iPhone's. I though it would be fine, not the case though. That explains all the weirdness that was going on. I deleted the field in the iPad's nib and everything is A Okay. Phillipe, thank you so much for your help and offer to look it over for me, that is incredibly generous.