To show you my issue I created a new Master-Detail-Application in Xcode 10.1 and with the deployment target iOS 12.1 (I tried other iOS versions too)
I want to change the text of the "Back" Button in the top left corner at the Detail View, which is by default "Master".
I have come up with the following code, which I wrote in the -(void)viewDidLoad method in DetailViewController.m .
self.navigationItem.leftBarButtonItem.title = NSLocalizedString(#"Menu", #"Menu");
[self.navigationItem setLeftBarButtonItem:self.navigationItem.leftBarButton animated:YES];
When I know start the App, the Button is how it should be, but as soon as I press it, it changes back to "Master" and stays that way.
I have tried to put this code anywhere you can imagine, but nothing worked.
I tried several other methods I found online and nothing else worked for me.
EDIT:
I just found out, it only affects iPad, when I test it on iPhone, the button displays correctly.
Related
i am making a very complicated app with a lot of classes.
my app worked great and i worked on it for the last month.
the last time i worked on it i added a function and it worked great, i saved the app and ran it a few times since and it worked. the last time i turned my computer on, it prompted me that an update for xcode is available. i updated it, and since then every time i run my app it runs with no errors but on ios simulator it shows a black screen. what can i do? i worked really hard on that app. thanks for the help in advance.
There's few issues that could happened, withou detailed description of this issue, you can try following solutions:
reset simulator
check if your initial controller is set up in storyboard(select controller and press attribute inspector, select is initial view controller):
if you're setting initial view controller programmatically, check if that controller is not nil in app delegate
another tip - try to use UI debugger, that helps a lot:
Any debug messages in the Xcode output? That usually will give a clue.
One thing I can think of, is that in your
- (void) applicationDidFinishLaunching:(UIApplication*)application
delegate, try setting the window's root view controller to your view controller. Example:
[window setRootViewController:viewController];
[window makeKeyAndVisible];
Again, the Xcode debug output will confirm if this is indeed the case though.
I have been working on this app for months now and from as far back as I can remember I have never had an issue with segues. The code is unchanged in terms of calling performSegueWithIdentifier but since my recent update to Xcode 7 and iOS 9 I have not been able to tack this issue.
I have tried:
Deleting button and creating new button w/ segue link
Using a direct segue from button to view, without the use of performSegueWithIdentifier
Connecting button to new blank viewController
When I press the button, no initial load functions are called on the destination VC (Ex: ViewDidLoad, ViewWillAppear, etc). When I connect it to a blank view, the segue works fine with the same code in place.
Since the code never stops, or breaks, and just seems to "freeze" in place while still running on Xcode I can't seem to even narrow this down to whats causing the issue. I have a similar segue that is also called from another button on the same ViewController that has no issues whatsoever.
Any thoughts on the matter are greatly appreciated!
EDIT: I have narrowed the issue down to the UITextView's causing the problem. Once the Text Views were removed the page loads fine via segue. I wonder what changed between iOS 8 and iOS 9 in terms of UITextView as I will have to remove the text views and completely re add new text views.
So basically the segue was freezing because of the UITextView's I was using in the destinationViewController. The following fixed the issue:
Delete all UITextView's
Add new UITextView's
you must leave the default lorem imposed text and change this programmatically in the viewDidLoad()
This was the fix for me, and from the research I have done on the issue it seems this is a bug in iOS 9 and Xcode 7.
Cheers!
NOTE: Removing the text in the UITextView (or making it longer then ~12 characters) is sufficient to work around it, no need to delete and recreate them. This is fixed in Xcode 7.1.1 and later.
I ran into the same issue and the fixes in this post (Xcode 7 crash: [NSLocalizableString length] 30000) solved the issue for me.
The first is to enable a localisation other than the base for the storyboard (see https://stackoverflow.com/a/32688815/3718974)
The second is to turn off the base localisation (see https://stackoverflow.com/a/32719247/3718974)
I think I have the same problem: I have a UITabelView with cells created from a nib file, when a user tap a cell this method is called:
and when I have the following method prepareForSegue:: the application crashes:
if I delete the line 129 Everything is ok , the method prepareForSegue:: open the right view and the label contactName is shown with its default text.
If I modify the method as follows prepareForSegue:: get exactly what you expect, without having any type of error:
let me know if you also get the same result
Any one who is facing this issue, i solved it by turning off the "Optimize rendering for windows scale" option in Debug of simulator window. I already had tried all of the above answers but could not solve the issue.
In the method in the first viewController where you activate the segue, do you have beginIgnoringInteractionEvents anywhere? If so the screen you segue to will be frozen and will ignore interaction events like you describe. If this is the case you can fix this by adding an endIgnoringInteractionEvents method before your segue method:
UIApplication.sharedApplication().endIgnoringInteractionEvents()
self.performSegueWithIdentifier("editItemToMyGearSegue", sender: self)
I realize this is an old topic, but appears to be still relevant. I was facing the same problem in Xcode 9, iOS11. My UITextViews are embedded inside UITableViewCells. Same symptoms as described here. The tricks with default text and placeholders did nothing for me, but I solved it by turning off the scrolling indicators for the text view in the xib. They were on by default, I guess, though unused.
Edit: this is probably an important detail... the views that were hanging all had an image NSTextAttachment in the attributed string of the text view. I think the image was wider than the available table cell content. With scrolling turned off, they appear to downscale.
My app allows the user to link other people within the app to entries in the contact book, and if one doesn't exist add a new one. I accomplish this by presenting an ABPeoplePickerNavigationController with an added button on the top for "Add Contact" which pushes an ABNewPersonViewController.
The problem I have is this functionality works perfectly in iOS 6, but completely fails to work properly in iOS 7. Clicking the "Done" button does absolutely nothing, and clicking "Cancel" simply stops the fields from being editable.
Has anyone encountered something like this and know how to fix it? Is this a known issue (Google search returned nothing useful"
Same problem for me.
My code was as follows,
ABNewPersonViewController *npvc = [[ABNewPersonViewController alloc] init];
npvc.view.backgroundColor = [UIColor colorWithRed:0.188 green:0.545 blue:0.016 alpha:1.0];
After I removed “npvc.view.backgroundColor =…”, it works fine.
Probably the structure of ABNewPersonViewController underneath has changed, so we are not allowed to set its background color.
I've got a puzzle. I'm a newbie and recently got my first app approved. However, I just noticed that a question mark icon that appears fine when I run the app in Xcode's iPad simulator is invisible for some reason in the actual app store app. The question mark is a UIBarButton item in the toolbar of the starting view controller in the app. The curious thing is the UIBarButton is obviously present in the actual app store app because when I click on that area of the screen, the information screen that it is supposed to show does indeed appear. But for some reason the button itself seems to be invisible in the app store app (but, again, the very same UIBarButton IS visible when I run my program on Xcode's iPad simulator).
One more piece of info: When I first start up the app downloaded from the app store on my iPad, the blue question mark actually does appear briefly in the toolbar of the app for about 1/4 second but then disappears.
Here below is the code segment which is in the viewDidLoad method of the starting view controller. The questionMarkBarButton property is a UIBarButtonItem which brings up an information screen when clicked.
[self.questionMarkBarButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:#"Helvetica-Bold" size:26.0], UITextAttributeFont,nil] forState:UIControlStateNormal];
Any ideas what could be causing this strange behavior? I'm at a loss how to proceed because apparently I can't debug this using Xcode's iPad simulators since they show that the question mark UIBarButtonItem is visible and behaves as expected.
Additonal Info:
Here's how the UIBarButtonItem is declared in the .h file of the view controller:
#property (weak, nonatomic) IBOutlet UIBarButtonItem *questionMarkBarButton;
It appears to be hooked up correctly, as evidenced by the fact that the button works (although it is invisible in the app downloaded from the App store).
Also, here is a picture of this part of the storyboard:
Finally here is what the starting screen looks like on the Xcode simulator. You can see the question mark button in the toolbar here, but for some reason it is invisible (although present) in the version of the app downloaded from the app store:
More info:
In examining my app again, I see that there later on in the app I again use a UIBarButtonItem to present an information screen, and it appears and works as it should. The most apparent difference between how I coded these UIBarButtonItems is that for this problematic "question mark" UIBarButtonItem I tried to make the question mark bolder and more prominent by putting the following line of code in the viewDidLoad method of the view controller, whereas I did not use the following line of code with the UIBarButtonItem that appears later in the app (i.e., I let the text in this other UIBarButtonItem just appear in its plain, default form).
[self.questionMarkBarButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:#"Helvetica-Bold" size:26.0], UITextAttributeFont,nil] forState:UIControlStateNormal];
So unless anyone has any better idea, I guess I'll just submit an update for my app in which I remove this line of code and let the question mark appear in its plain, default style rather then an enlarged, bold style.
Final edit (12/7/13)
I removed the code line above and resubmitted my app to the App Store. The app now works properly, with the "?" information button now showing. The bottom line appears to be that the setTitleTextAttributes method does not currently appear to be a good, reliable method to use with UIBarButtonItem objects. It will appear to work fine in the Xcode simulator, and even in testing with your own iPhone and iPods, but for some reason it will not work when people download the app from the Apple store.
Objective c is case sensitive, Make sure your bar button variable that you create and assign are same . hope this may help you. as this is one of the issue when things go right for simulator instead of device.
I'm presenting an MFMessageComposeViewController which works fine with iOS4 and iOS 5 but has problems with iOS6.
The view is presented ok but if its dismissed and then represented it doesn't display correctly - only the To: line is displayed, the body and keyboard are missing. (Sorry I can't post a screen shot at the moment as XCode crashes when I take a shot, I'm downloading an older version of XCode as I type).
Stepping through the code in the debugger I noticed that the problem may originate earlier than the re-presenting - I noticed than when dismissViewControllerAnimated: gets called the entire view does not get dismissed immediately, rather it is the message body and keyboard that gets dismissed leaving behind the To:, the same thing that is displayed when the view is re-presented.
It might be easier to describe with screenshot, I'll post some shortly.
I'm using presentViewController: and dismissViewControllerAnimated: to present/dismiss the MFMessageComposeViewController.
+++ UPDATE +++
I've found the problem can be solved if instead of using the same MFMessageComposeViewController object to re-present the view I first delete it and then create a new one.
That seems a little inefficient though, and it should not be necessary I'd have though, like i mentioned it worked on iOS5.
In iOS 6 apple introduced a new feature "remote view controller". Some external view controllers are no longer part of your app, and the messaging controller is one of them.
I guess that is the problem in your case.
you can read more about it there: http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/