My application consists of 2 windows.
The first window is the main window. It has an NSTextView and an NSView.
The second window is the preferences page. It has an NSColorWell which would change the background color of the NSView on the main window via a shared instance of a class that I called MainDATA.
When I press the build/run button in xCode, the app works perfectly. Everything functions as is should.
When I archive and export my app, everything works excepts except for the background color change. When I open the app, the background is initially set as it should be, but when I change the color with the ColorWell, the background doesn't update.
The background updates its color using a thread that would call [self setNeedsDisplay:YES] in another method by using performSelectorOnMainThread.
I have no idea how to troubleshoot this because like I said, everything works perfectly when testing the app.
Any ideas?
Update: Just found out that the reason it isn't updating is because threads aren't starting. Still not sure why.
Ahhh!
That was frustrating...
I just found out that while(true){}loops DON'T work in archived applications. If anyone wants to explain to me why it is like that, let me know.
I hope this answer helps some people avoid the confusion and frustration I just went through:)
Related
I have created two UIViewControllers in IB.
PROBLEM 1: I can't make the 2. VC transparent.
I have read a lot of stackOverFlow solutions but nothing seems to work in my case.
I have tried the following setup in IB both in my current project and in this simple project and something strange occurs (IB,for 2.VC):
Setting the alpha value below 0,5
Setting opaque to "checked"
Setting the background color to "black"
https://imageshack.com/i/kqdXWk9Jp
The second VC gets pushed when I click "GO TO NEXT VC" (push or modally , doesn't matter) and while he is being pushed I see the the result I want:
https://imageshack.com/i/idXUCFCPp
... and when the push is finished the new VC changes from being transparent to black (not transparent):
https://imageshack.com/i/iqmLw8D1p
I have no clue why this is happening and I cant get it to stop working like that.
Q1: Why is this happening?
Q2: Why can't I change the properties of the views programmatically when the views are created with IB?
I have done this thousand times WITHOUT using IB. As soon as I start using IB things don't work like they are supposed especially when I try to edit stuff programmatically.
When I do all of these steps without IB only in code everything works perfectly fine but I need to use the IB in my next project. I am using Xcode 5.1.1. on mac mini (late 2009) with Mavericks.
Sorry for bad English.
Your problem is because the memory management of iOS removes the previous interface ViewController, to save resources.
After iOS7, you can customize the transition viewControllers. Please read: UIViewControllerAnimatedTransitioning Protocol Reference.
I also had the same problem and managed to solve it by following the tutorial Custom UIViewController Transitions.
If you are still having doubts, there is another tutorial to help you: iOS7: Custom Transitions.
Hope you get success!
I found that a previously normally working iPad storyboard started working weirdly upon introducing auto-layout. In particular it seems not to properly show different ViewControllers when clicking different annotations but instead it always shows the first one whatever more annotations are clicked. When I disable auto-layout everything works fine again. Apple responded to my request hinting to a problem in the handling of segues:
#Apple: 'When running a segue from A -> B, it is not our intention that that segue over and over again will result in a chain like A -> B -> C -> D because the original transition is A -> B. However it would make sense if you had a self-referencing segue and you called performSegueWithIdentifier over and over again because you in that case are having the same instance just added to itself. I think you were just getting lucky before and that turning auto layout on was just enough to point that out.'
Yet all the hits I found on the web like in:
How to call a segue from a disclosure button on a map pin?
and
MKMapView show DetailView - How to make a segue
are quite the same as the the code I used and Apple says it is wrong; notwithstanding the iPhone version keeps on working and the problem just arises on the iPad.
Any hint before they crank up another funny suggestion?
Unfortunately the problem, the way it went the way it returned. Eschewing the possibility I ran mad, the same code including the one on the iTunes Store now, started presenting the problem again. I also tested it on another iPad and it presents the same problem leaving me totally in the dark. All the thing seems crazy.
I have a standard NSWindow with a toolbar. One of the toolbar's items is a custom view -- specifically, an NSTextField. (More specifically, it's a timer app -- the timer's controls as well as the digital display are all within the toolbar, with other stuff in the window's content area. The NSTextField is the digital display.)
Ordinarily, I just update the timer every second by changing the 'stringValue' property of the NSTextField, which causes it to update itself. But during a live window resize, even though the code that updates the 'stringValue' property is running (which I have verified with NSLog), the NSTextField doesn't draw itself again until the window resizing is done. Meanwhile, the stuff inside the content area is updating itself just fine.
I've tried all the ways I know to tell the NSTextField to draw itself, but it just refuses to happen until the live resize is done. Any ideas? Obviously it must be possible somehow, as the toolbar gets resized along with the rest of the window -- so you'd think it would be possible to force it to redraw one or more of its subviews as it is moving them around. I'm assuming I can hack this together by subclassing something, but my Cocoa-fu is not yet strong enough to figure out the easiest/most proper way to do so.
Thanks in advance...
EDIT: I kind of figured out a solution -- it's not great but it mostly works for now. It's in my comments below.
Just invoke -[NSWindow displayIfNeeded] after marking the view as needing display. I encountered this problem when implementing the Mac driver for Wine (an open-source project for running Windows software on OS X and other Unix-like OSes).
http://source.winehq.org/source/dlls/winemac.drv/cocoa_window.m?v=wine-1.7.11#L1905
(That's LGPL code, so you want to consider before copying it. But you can learn implementation techniques from it without worry.)
My iPhone application has just suddenly changed behavior and I have no idea why. I have a small button and it is now only firing on touch up outside and not touch up inside. I'm not aware of anything I changed that may have caused this.
As you can see from the image below, it is correctly wired for touch up inside to the onAdd selector.
Any ideas on what could cause this behavior?
Check GestureRecognizers, other IBActions in this view. Try to link up event with touchUpOutside and check is it working ok, then revert to Inside and check behaviour. Use NSLog in methods to see what's firing on tap. Without sample code I can't say much more.
I have a very very old iPhone/iPad app, actually it was my very first Objective-C app, I started learning iOS programming on it. Now I want to update it a bit but have following problem:
The app has never had any viewController. When I started writing it, I wasn't familiar with MCV and Interface Builder. First version was just for iPhone and it made the UI manually by just positioning UILabels and UIButtons in UIApplicationDelegate's didFinishLaunchingWithOptions via addSubview directly into self.window (there is MainWindow.xib but it's empty). A couple of months later I created iPad version. It has all the UI created in Interface Builder in a single MainWindow_iPad.xib. There are no other xibs, just UILables and UIButtons placed directly in MainWindow_iPad.xib and no view controller was used again.
Now, a couple of years later, I want to update this veteran app a bit. I want to add a root view controller so I set window.rootViewController in UIApplicationDelegate's didFinishLaunchingWithOptions. I have no problem with the iPhone version, it works a treat. But I have troubles with the iPad one. After setting window.rootViewController, the app doesn't interact to any touch at all. It loads, the UI is created but it's just frozen.
Any idea what could be wrong? Thanks a lot!
Don't tell me I should throw it away and write it again from scratch in a normal "experienced way", I know this would be the best way but I don't need to update it that much to waste so much time.