iOS8 Button setEnabled doesn't work - ios

I just downloaded the iOS8 GM Seed, and found that my UIButtons, which are setEnabled when in app purchases are bought, are not working.
In
- (void)viewDidLoad
I have
[mainToneBtn setEnabled:YES];
Pre-iOS8 this updates the button to be clickable, but not now. I haven't done any changes pertaining to this, and in debug, the code above is hit. No code sets it back to setEnabled:NO.
Any ideas?
Thanks.

I am unable to reproduce your problem. It seems, for whatever reason, that ViewDidLoad is now too early in the ViewController lifecycle for you to enable your buttons. I would suggest trying to enable them later in ViewDidLayoutSubviews.

For some reason this works,
[self performSelector:#selector(updateAllInAppPurchases) withObject:nil afterDelay:0.001];
the button code is within updateAllInAppPurchases
but I have no idea why I have to do this in ios8. I will accept the answer of anyone who can give me a good explanation, thanks!

Related

Black screen on app launch after latest Xcode 7.2 update

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.

iOS Swift orientation change animation missing

I'm writing an app in Swift 2.0. The app works fine in every aspect, beside one.
When I tilt the screen of both device and emulator the orientation change animation is missing. Instead of a smooth rotation I get a clunky orientation change. Portrait -> Landscape. Nothing in between.
Giving the fact that the animation should be the default, I would like to know if anybody knows the possible solution to this problem. I searched everywhere and apparently nobody has this problem, instead people try to disable that animation!
After some tests and thanks to Zell.B, I moved the code from didFinishLaunchWithOptions to applicationDidBecomeActive and everything works fine.
Deleting the applicationDidFinishLaunching method from the app delegate class can also cause the lack of animation problem. Adding it back in can fix it.

UITextView freezes iPad app from textViewShouldBeginEditing. (Invalid Glyph Index)

So I've been working on this bug for about a week now, and for the life of me I can't figure out what's happening.
Due to confidentiality issues I can't post too much code, but I'll do my best to explain everything.
What's happening is that we're populating a UITextField via code, and initially have the text greyed out. The user then can do one of two things:
1) Tap a button which says "commit" and a method is called which does the following method we'll call "commitData". It does the following:
Registers the commit with an undo Manager
Changes the text from grey to black
Register with our application that the text field has been updated and needs to be saved upon application close
2) Tap on the text field with the greyed out text, which then calls the following default apple method textViewShouldBeginEditing. From here we call our "commitData" method listed from option 1 like so:
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
if ([[self box] hasGreyedOutText])
[[self box] commitData];
[self setActiveTextView:textView];
return YES;
}
The issue we're having is that tapping the button to commit the greyed out text works perfectly fine, and we run into no issues.
HOWEVER
When we tap into the text field and trigger the textViewShouldBeginEditing method, our iPads can freeze up and make the user wait for a couple of minutes before finishing. When I mean freeze, I mean the entire iPad freezes. The iPad clock won't even update while this is happening.
When this happens, we get an error code in the console which says:
!!! _NSLayoutTreeLineFragmentRectForGlyphAtIndex invalid glyph index 2147483647
We can get the error code above to display from all of our hardware when following the steps above, but can only reproduce the freezing on an iPad 2(with 100% accuracy however).
A note on this, my co-worker has found through diagnostics that we only have about 8MB of free RAM when this error occurs. We only ever hit this little of RAM on the iPad 2 however, so this could just be a coincidence.
I have a feeling that this could be related to threading and that we might need to somehow call our method after returning YES from the textViewShouldBeginEditing method, but I'm not quite sure how I should be going about that.
If anybody has any ideas on how to fix this, or even ideas that could point me in the right direction, I would be incredibly grateful. I've looked everywhere I can possibly think of, and none of the solutions I've found relating to the error code have ended up working.
I can't debug, so in my guess it may caused by non-main thread UI operation. So, my suggestion is to make sure your UI code is in mainThread. Try this:
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
dispatch_async(dispatch_get_main_queue(), ^{
if ([[self box] hasGreyedOutText])
[[self box] commitData];
[self setActiveTextView:textView];
}
return YES;
}

ios8 UIModalTransitionStylePartialCurl doesn't work properly

Under ios 8 using presentViewController modalTransitionStyle = UIModalTransitionStylePartialCurl disappear all page.
I want it to work like ios 7.
I had the same issue and I applied this fix, it worked for me on iOS 8 and Xcode 6.
[_mapToolbarController setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentViewController:_mapToolbarController animated:YES completion:^{
[_mapToolbarController.view.superview addSubview:self.view];
}];
Obviously, _mapToolbarController will be the controller that you want to present. To see why you'd need this, add a breakpoint at the line in the completion handler. Do the animation, and you'll see in the completion handler that the curling animation had just finished and everything was perfectly fine. For some reason that I can't explain, in iOS 8 you'll need to tell the iOS framework to "keep" the curled view and make sure it doesn't get thrown away. The code in the completion handler tries to "keep" the soon-to-be-faded curled view onto the screen. Note that in this context, self.view is the view that is being curled.
You can always try to make your own transitions with iOS 7. Have a look HERE
Well, I am not proud of the fix I came up with but it works just fine and took me little time to do it.
I managed to get a screen shot of the page curl at the stage that I wanted it to remain. It took a few tries but I got it. Then I took that image into Pixelmator and cropped it to just the page curl portion, made everything else transparent, smudged out the extraneous artifacts like the battery indicator, signal bars and time.
I imported that image in 320, 640 and 960 widths then insert it at the top of my presented view at load time. It came out virtually perfect. I cannot tell the difference from what I had before. Works exactly as I wanted it.

Disabling user interaction not working in SVProgressHUD on iOS app

I've just downloaded SVProgressHUD and incorporated it into my project as explained in the github documentation page, but even if I wrote out [SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeGradient];, it's not different from the default mask type, and when I tapped the screen while the cursor was revolving I got my app crashed - meaning I wasn't able to disable the user interaction feature since my app crashes before showing all of the table view cells there.
And note that clear or black mask type didn't work, either.
So how can I successfully disable the user interaction? And which file of the AppDelegate.m's applicationDidFinishWithLaunchingOptions: and FirstViewController.'s viewDidLoad: should I write the above code?
I use the latest version of the SVProgressHUD and use Xcode 5.1 and iOS 7.1. I also use ARC. Am I missing something?
[Update]
This was a bug issue and it has been resolved in the current version. Check it out on the Github page for the further info.
This is very late to answer but just in case it can help someone because I was stuck with this issue for a while today. If you are using latest classes from github you won't face any issue but if you are using old classes then Replace below method from SVProgressHUD.m as below
+ (void)showWithStatus:(NSString *)status
{
[self setDefaultMaskType:SVProgressHUDMaskTypeGradient];
[self showProgress:SVProgressHUDUndefinedProgress status:status];
}
I am using SVProgressHUD with swift and iOS 10.2 . Just setting mask type
In AppDelegate
SVProgressHUD.setDefaultMaskType(.black) works.
and every time you write
SVProgressHUD.show()
it will show the mask and userInteraction is managed by it.
You're not missing anything. iOS 7 doesn't seem to respect the mask type, so user interaction is never disabled. I think it's a bug with SVProgressHUD rather than anything else. Bit frustrating really.
It can be done easily by doing some changes in SVProgressHUD class:
just put
[self.window setUserInteractionEnabled:NO]; in the last of showprogress with status and put [self.window setUserInteractionEnabled:YES]; in dismiss method.
Objective C (AppDelegate.m)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//add this line
[SVProgressHUD setDefaultMaskType: SVProgressHUDMaskTypeBlack];
}

Resources