On Dec 24, 2014, at 8:26 PM, Quincey Morris <[email protected]> wrote:
> >> On Dec 24, 2014, at 19:30 , N!K <[email protected]> wrote: >> >> Thank you all for explaining what’s going on. I looked up initWithCoder; it >> is not suitable for my usage. >> >> I have tried again, adding a custom view assigned to class StretchView.* >> Still no luck, initWiithFrame is ignored. Again, strokeRect puts on a >> colored frame, but no Bezier path appears. >> >> If both icons, View (system supplied) and StretchView (my addition), are >> assigned to class StretchView, both get the frame but no path. >> >> Note that both icons are blue, so shouldn’t both get to initWithFrame? >> Please refer to the ScreenShot from .xib below. >> >> A further question: Would it be worthwhile to get rid of the (system) View? >> If so, how? Deleting StretchView from both Class assignments in the >> Inspector did not remove or disconnect them. Framed views remained the same. > > You're dealing with at least three issues here, and you’re not going to get > anywhere until you disentangle them. > > 1. The view that’s immediately below the window in the view hierarchy is the > window’s content view. You shouldn’t be trying to customize this view — treat > it merely as the parent of all your views — and you certainly cannot delete > it. > > 2. Since views with your custom class are drawing something (the frame), you > know that the view exists and is using the correct override of drawRect:. If > nothing else is drawing, that’s a bug in your code. Given the circumstances, > that might be because some required initialization of drawing parameters > isn’t happening, so there’s no point in even trying to chase this down while > you still have an initialization issue. > > 3. You have an initialization problem. It’s vital that you diagnose this > *before* you go chasing other problems. As Roland said, you should start by > working out *which* init… method is being called, by providing overrides in > your custom class and using breakpoints or logging to find out which one(s) > are called. Again as Roland said, you should override ‘init’, > ‘initWithCoder:’ and ‘initWithFrame:’. It’s not important what your overrides > *do*, at this stage, only important to know which of them is being called. Following Roland’s lead, initWithCoder: is required. > > View initialization in Cocoa isn’t broken, we’d actually notice if it was. If > no init method is apparently being called, then you’ve done something wrong. > It could be something simple (like spelling the method name ‘initwithFrame:’) > or something more subtle, but I guarantee you that your method isn’t failing > to be called because Cocoa is doing something wrong. This thought never occurred to me. > Once you accept that premise, you’ll be closer to a solution. I realize that I don’t know enough Cocoa to challenge the system. But someday I may learn enough to be able to file a valid bug report. :) > It’s also worth considering how you know that ‘initWithFrame:’ isn’t being > called. Debugger? Logging? Both. > One potential issue is that your CVone window is apparently in your main menu > NIB file, which is actually a fairly bad place for it to be Why bad, and where else could it go? I’ve always followed book examples for single and multiple views by dragging a custom view icon onto the .xib view in the .xib window, and then it always shows up as seen here: > (though Apple’s templates for a single-window app do put it there). If it’s > there, and you fail to *un*check the window’s “visible at launch” flag, Where is this flag located? I’m using OS X 6.1.1, desktop. > the window and its view may be created much earlier in the app startup > process than you expect. This may be contributing to the confusion. > Maybe this will cast some light on the timing: Now that the project is running with initWithCoder:, I’ve found that drawRect runs twice before putting up a window, in which the plot is displayed twice. One is scaled from the other. After the first drawRect, the size of the Bezier plot is changed somehow, from a few percent to as much as 50%. I observe the size of the plot with CGRect x =[_path bounds]; This seems abnormal to me, and it has a significant effect on the presentation of the data. I would appreciate guidance on debugging and fixing this. Thanks, Nick
_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com This email sent to [email protected]
