I'm working on an app where I have a subclass of a UIView that contains seven subviews with orientations arranged such that they form a 7-sided shape. Each of these subviews has additional subviews in front of them that are oriented the same way as the main view.
Fine so far. Then I tried adding some code to tap into core location services. I used the basic procedure outlined at this tutorial. Using the code as it is presented there, I successfully got the heading to display in the debugger window.
Next step was to tie it into my app. To make sure I was on the right track, I simply added this code:
float radianHeading = newHeading.trueHeading * M_PI / 180;
CGAffineTransform transformTrollCalendar = CGAffineTransformMakeRotation(radianHeading);
[self setTransform:transformTrollCalendar];
There are two issues. The first is that the view is not visibly rotated. I was prepared for that, because I probably have to trigger something to redraw the view. However, I get another problem that has me worried.
When I get a bunch of updates from the compass, the connection between my mac and my iPad gets lost, as evidenced by the stop button turning grey. Moments later, the iPad makes the sound that you get when you connect the cable to the Mac or power. Then I get the slider that you get when you first power up the iPad. I figure this means I'm doing something majorly wrong. However, the app still appears to be running on the iPad, and it is not generating any crash logs.
I resolved my own problem. Apparently, the problem was the result of my putting the code into the wrong method. I don't remember anymore which wrong method I placed the code into, but when I placed it in the correct method, it worked just fine.
I would have updated this sooner, when it was still fresh on my mind, but I've had a trip to Guatemala in the interim that has caused my memories of this problem to fade.
Related
I apologize if this has been asked before. I tried searching for this first and nothing is coming up. I'm pretty new to Unreal Engine 5.1 so this might be something I'm doing as well.
I've been exploring animation retargeting in unreal and have tried following the steps we learned in class using one of the models from mixamo.com. Everything appears to work fine at the start and I can get the actual IK and IKR objects working just fine. However when I try to export the animations either from the IKR object or by right clicking the ABP object for the source mesh one and only one of the animation sequences rotates 90*. It is always the same animation (the Land animation sequence) and I'm not sure how to go about fixing it.
Also tried looking on google and turned up nothing.
I'm hoping this is some stupid newb mistake that is easy to fix or maybe there's something I'm overlooking. Any help is greatly appreciated and I will continue trying to fix the problem myself as well and will post if I fix it
Tried retargeting using the following steps
Create an IK_Object for the model you wish to project your animations on with chains for each. Mine looked like the following
IK_Remy
Repeat step 1 for the model you wish to source animations from. Mine looked like the following
IK_Manny
Create an IKR_Object Linking the two together, here's what mine looked like
IKR_Remy
Find the ABP for your source model, right click, and select "Retarget Animation Assets->Duplicate and Retarget Animation Assets". Here's what I'm selecting for that
Retarget Dialog
When I do the following most of the animation sequences for "Manny" export just fine. However the "Land" animation flips for some reason (see image below)
Exported Animation Images
Even stranger, when I preview the MM_Land animation in my IKR object it looks fine i.e. not rotated. However, if I try to export the animation from the IKR object the same thing happens i.e. it rotates 90*. I would expect this to be a case of WYSIWYG where if it's working in the preview it would export correctly. However that apparently is not the case
Also I tried modifying the animation sequence manually but it won't let me. If I try to rotate the model in the animation sequence and save it, once I close the sequence it's re-rotated and the changes do not persist.
I can export the sequence as a new sequence, modify it, and save it, and then rename it as my exported "Land" animation to hard force it and it at least looks normal. However when I actually play the game and jump, when the land animation it still flips sideways and in addition causes the character to scale and warp for a second which makes me think there's something going on here that I don't know enough to fix. Really hoping someone with more experience in Unreal Engine can help.
EDIT: Fixed Image Descriptions
I can confirm that this is an issue - I'm seeing the same behaviour. I haven't managed to fix it yet, but my suspicion is that it's due to scaling - in my instance, I have had to scale up my custom character by around 2.5 times to replicate the scale of the default mannequin. Did you scale your custom character at all?
I'm making a simple game and just messing around with SDL. I have two images currently, and I am practicing making them the background. I make one the background by calling RenderCopy, the DestroyTexture to clear it from memory, and then I present it. I changed the file path from one image to the other to change the background. I ran the program, and now the new image is layered on top of the other. I can fix this problem if I manually do a clean of my computer's memory, and it renders properly. For some reason, SDL is not clearing the image called previously. There is no mention of the old image anywhere else in the code, and all the Destroy functions are called. What is going on?
Edit: I did a little bit of snooping and its not that it even loads the old image; whatever the final render displayed on any program running SDL was before it was run, it will be the background. It is literally like a TV burning an image into the screen; its always there.
The problem was fixed by simply clearing the frame between frames. Didn't have any performance impact.
Bear with me on this one, as it's been frustrating me for a few days. This seems like it should be really simple, but for some reason I keep running into a series of frustrating problems. I've done more work on iOS in the past, and never had these kinds of problems that I'm having on OS X. I'm wondering if I'm not understanding something fundamental about the view architecture in AppKit. In particular, I am not very familar with the interaction between layer-backed views and plain views as I have not needed to animate anything on OS X before (and because iOS makes all views layer-backed by default).
Anyway, I'm having some major problems with trying to rotate an NSTextView object by 45 degrees. The text is for some labels that get placed in a larger custom NSView subclass, but most of that seems irrelevant to this specific problem. I'll go through what I've tried and the problems I had. The position of the labels is basically static, so I don't care about whether or not they are animatable or not. The labels need to be created and placed programmatically, not from IB, as their size and position is dependent on dynamically generated data. If it matters, the NSTextViews are using attributed strings.
1) I first did this the way that seemed most straightforward to me, which was simply to set frames for the NSTextView labels, added them as subviews to the graph object, and then called [labelTextView setFrameRotation:45] on them. This worked perfectly on Mountain Lion, but when I tested it on Lion the label height that gets drawn on screen gets increased mysteriously (even though when I log the frame afterwards it is unchanged). That isn't acceptable because I need it to draw a background color for the label so that it looks readable when overlaid onto the graph. So on Lion there is a bug or something in setFrameRotation as applied to NSTextView (or so it would seem). Does anyone know what is going on with that? It's very annoying that it works correctly on 10.8 but not on 10.7. SetFrameCenterRotation has the same problem. Making the view layer-backed, or not, seems to make no difference.
2) I next tried to do this using CATransform3DMakeRotation, after making the parent view and the NSTextView layer-backed. I used the line labelTextView.layer.transform = CATransform3DMakeRotation(M_PI_4, 0, 0, 1.0);, but the text view doesn't rotate when I do this. As a test, I tried the same thing using a plain NSView with a colored background, and it does rotate correctly. Does anyone know possible reasons why this wouldn't work with an NSTextView?
3) I tried enclosing the NSTextView in a NSView container and then calling setFrameRotation on that. This does rotate it correctly, but somehow triggers an infinite recursion in Core Animation that quickly consumes gigabytes of RAM unless I kill the process! Again, any ideas about what's going on there?!?
4) I tried all of this using Autolayout to position the labels AND positioning them manually by setting their frames. No differences in results either way.
5) I could do this using completely custom drawing, but that would be a LOT of work in this particular case. I'd rather not do that just to support 10.7. I also could try NSTextField to see if it suffers from the same thing in part 1), but that would be annoying because I want some of the features of NSTextView (this isn't just a single line blob of text).
What am I doing wrong here? I never imagined something this simple being this difficult to get working correctly on 10.7 + 10.8.
UPDATE:
I tried substituting NSTextField for NSTextView and the problem in 3) goes away (the paragraph styling isn't exactly how I want it yet, but I can possibly fix that). Any ideas on why NSTextView has such problems with being rotated where NSTextField apparently doesn't? That seems insane to me. I'll try NSTextField without the container next to see if it also suffers from the drawing glitch on Lion.
UPDATE 2:
I tried just using an NSTextField instead of an NSTextView and rotating it, and that also worked completely fine on both Lion and Mountain Lion. The visual glitch where the size of the text view changes after rotation also disappears. So I guess the answer is that NSTextView is just totally incapable of having its frame rotated without triggering multiple bugs (especially on older versions of OS X). If that's the case, and NSTextView isn't intended to be used that way, Apple's docs should probably say so. Can anyone confirm that that is the case?
So my current app project is a camera based app and all is going well so far but I have run in to a weird little issue and don't know if there's something basic i'm missing or if it's something more complex.
When I run my app on the iPad in landscape mode (right hand home button), the right end of the screen doesn't recognise touch down events, though if an item is spread across the border (half recognising touches, half not) and you press on the good half and drag, it still recognises the touch and also recognises the touch up event when you let go. Through testing, I worked out that it works fine up to pixel 768 so this makes me think that one of the views thinks that the application is still running in portrait. But then when I run it in portrait, the bottom section (same portion) doesn't work either.
I have looked at another couple of posts on SO:
Article 1
Article 2
I have tried the fixes they say, but have had no luck as of yet. It may be something to do with the fact I have various different views created both programatically and in the interface builder and somewhere along the way, something isn't being initialised correctly but I have tried changing them all, I may have missed some though.
If anybody can shed any light on my situation, that would be greatly appreciated.
Thanks,
Matt
I think the problem has something to do with autoresizing mask. Have you set this? Try to set the background color of all views to see where they are.
I'm coding an application on Ipad, in a certain point of my application I present a ViewController with the presentModalViewController.
My ViewController is a UISScrollView who take the larger of the modalView and inside it I display some images, I allow pagingEnabled so I can see all my images inside the scrollView.
Sometimes I have to display more than 10 images inside the scrollView, so I have this error
RECEIVE MEMORY WARNING LEVEL=1 after this one RECEIVE MEMORY WARNING LEVEL=2 and finnaly the debugger exited due to signal 10 (Sigbus).
What can I do? is there a way to unload the image thats offscreen? or others things to do?
Thanks,
I guess you're adding all the images to the UIScrollView? Then the iPad has to keep all 10 images in memory. If they are full screen images, each of them will take up about 3 MB of memory, so you're using 30MB just to keep the 10 images in the scroll view.
You should only add the one or two images that are actually visible. Once they scroll out of sight, remove the UIImageView from your UIScrollView (and make sure you don't retain it anywhere else so it can be deallocated). When a new image scrolls into sight, add it to the UIScrollView only then.
In your UIScrollViewDelegate method -scrollViewDidScroll: get the current contentOffset and use that to calculate which images are visible.
Actually, this problem is even worse on the iPhone 3G, which can't even manage to display two full size photos (taken with it's own camera) at the same time.
If you can make the photos smaller ahead of time by resizing them (server side if you're snagging them from your own services, or client side if they're somehow generated on the device or retrieved from third party services), you should. They will load faster, and you can put more of them on the screen at once without running into memory issues.
The Three20 library has a really great photo-browsing control for the iPhone. I'm pretty sure they only have three photos around at any given time... the photo you're looking at, and the photos going forward or backwards.
http://github.com/facebook/three20
I also think there is an iPad branch of the Three20 controls (at ./tree/ipad), although I don't know if they include the photo browser or not, and haven't tried them yet myself... maybe that's an option for you if you don't want to spend a lot of time on that particular feature of your application. If the iPad photo browser isn't done maybe you could just adapt the iPhone version to suit your needs (shouldn't be hard).
If you want to bake the feature yourself, I'd take some inspiration from the UITableViewController. Your controller should come with associated datasource and delegate protocols to retrieve photos and respond to user events. The controller base class itself should reuse three UIImageViews and should shuffle those around to create the illusion that the user is scrolling through a large list.