UIBarButtonItem appears in iPad simulator but not in actual app - ios

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.

Related

Master-Detail-Application change the "Back" Button iPad(Objective-C)

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.

iOS 9 Segue Causes App To Freeze (no crash or error thrown)

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.

Unable to configure launch screen appearance using view controller file

I have a LaunchScreen.storyboard which serves as the launch screen file. In this storyboard is a view controller with the class LaunchViewController.
In my LaunchViewController.m file I changed the view's background color and added a label with the FB shimmering effect (https://github.com/facebook/Shimmer).
_shimmeringView = [[FBShimmeringView alloc] init];
_shimmeringView.shimmering = YES;
_shimmeringView.shimmeringBeginFadeDuration = 0.3;
_shimmeringView.shimmeringOpacity = 0.3;
[self.view addSubview:_shimmeringView];
_logoLabel = [[UILabel alloc] initWithFrame:_shimmeringView.bounds];
_logoLabel.text = #"Shimmer";
_logoLabel.font = [UIFont fontWithName:#"HelveticaNeue-UltraLight" size:60.0];
_logoLabel.textColor = [UIColor whiteColor];
_logoLabel.textAlignment = NSTextAlignmentCenter;
_logoLabel.backgroundColor = [UIColor clearColor];
_shimmeringView.contentView = _logoLabel;
But when I ran it there's only an empty white background displayed as the launch screen. Also I find that he LaunchViewController looks fine when used as a regular view controller. How to make it display the same effect when used as launch screen?
You can't use code inside a launch view controller nib. Whether it is a storyboard or a separate nib. The code is not executed. The only thing that works is what is in InterfaceBuilder like auto layout and stuff. No code is loaded. This would defeat the purpose of using a launch file. The launcfile is loaded before the app has had chance to load.
No app, no code. Only the launch file.
I've had similar problems, and based on your code, it may be similar to mine. First off, I don't understand your question as much as I would like to. You said, "The LaunchViewController works fine when not used as launch screen." Does that mean that it looks the way you want it to look like when viewing on Xcode, but not on the simulator? I will try to provide possible solutions, and some trouble-shooting tips.
It could be something as simple as your background(or something) is at the front of the screen, blocking the rest. If so, you have to reconfigure the order of your items on your launch screen in your xib file in your application.
It could be an error on your part. Some of my programmer friends develop their launch screens using the Xcode interface: I find that easier to use, and it may have less errors.
It could be an issue with the iOS simulator. This is not likely to be true, but it could be. Try running the app on your device and see if it is fine there.
Troubleshooting: In order to trouble shoot your code, comment out your code, and load in all the elements of your launch screen one at a time, checking the iOS simulator and the console in between. You will eventually find the problematic code, and be able to fix it. From looking at your code, I don't see anything wrong (but don't take my word on it, I'm not familiar with coding the launchscreen/storyboard in swift. Good luck, and I hope my tips work. Also, if your launch screen is appearing fine inside Xcode, it is a programming error or an error on the iOS simulator. A picture or a description of your launch screen could also help future people who will answer this question.

ABNewPersonViewController broken in iOS 7

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.

Issue with updating app and UITextView

I have an app that has a UITextView in it. The user presses a button and the action changes the text on the UITextView. The app is functional and in the AppStore right now, it was built using iOS 4.2.
With out changing anything with the code. When testing a new version of the app building it for iOS 6. the app will not show any text in the UITextView when installed in the simulator or new device. The UITextView is blank...but when using an NSLog it writes to the log that there is text in the UITextView.
I have noticed that if the device had the previous version of the app, which is in the AppStore. And I compile the new version of the app onto that device, the app functions like it is suppose to and the UITextView is updated when the button is pressed.
in my .h file
#import <UIKit/UIKit.h>
#interface TimeSheetViewController : UIViewController <UITextViewDelegate>
{
}
#property(nonatomic, retain) IBOutlet UITextView *logTextView;
in my .m file
#synthesize logTextView;
-(IBAction)buttonAction
{
logTextView.text = [NSString stringWithFormat:#"%# \n New words go here...", logTextView.text];
NSLog(#"%#", logTextView.text);
}
Even trying to have text set from the UITextView from the Interface Builder fails to show up unless the app is pre-existing when the new version is compiled onto the device
Try using the setText method of the textview.
[logTextView setText:#" New words go here..."];
If it doesnt work, check if you have set the textView as not editable ie user interaction disabled or anything like that in xib file if you have one.
This is only a half answer or more precisely not a solution... according to
Technical Note TN2285: Testing iOS App Updates
Warning: Do not use Xcode to install or run updates to your app for quality assurance testing.
To make the development cycle faster, Xcode only pushes changed files
into the apps it runs, and does not delete files from existing
app-bundles. This makes builds significantly faster. But it means that
using Xcode to install an app over an older old build can make a
"frankenbuild" with legacy files it wouldn't otherwise have. This can
cause problems during testing and mask bugs.
Additionally, running with Xcode will mask "watchdog crashes" that can
happen if an upgrade takes too long to launch.
I believe what is going on is that, some file is being left behind from the AppStore version when I compile my new version from Xcode onto it....making it work like it is suppose to.
But since the file is missing in the new version compiled from Xcode, any new installs of the app from the unreleased future version of the app are missing that particular file and are not functioning correctly.
I'm not quite sure what the file is, but I intend to look into it more or build a new project and copy and paste the old code into it.
Testing Your App on Many Devices and iOS Versions
I was using the following code in the viewDidLoad method:
int fontSizeA = [(sizeLabel.text)intValue];
logTextView2.font=[UIFont fontWithName:#"Arial" size:fontSizeA];
The problem I ran into was that the sizeLabel become disconnected in the Interface Builder and the viewDidLoad method was really using this code...
int fontSizeA = [(#"sizeLabel")intValue];
logTextView2.font=[UIFont fontWithName:#"Arial" size:fontSizeA];
which gave the appearance that there was no text in the UITextView.

Resources