CGRect Frame Issue - uiview

I keep getting a reoccurring issue while testing on iOS 7, I cannot figure out if its a BETA bug that has not been properly addressed or if its my code, or still if its a configuration problem.
I am trying to animate a UIView,
In my .h i have defined it like this
IBOutlet UIView *MainView;
#property (strong, nonatomic) IBOutlet UIView *MainView;
And in my .m this is the code. Its not a connection issue as the opacity (alpha) animation works just fine.
[UIView animateWithDuration:4.3 animations:^{
[settingView.view setFrame:CGRectMake(160, 0, self.view.frame.size.width, self.view.frame.size.height)];
MainView.alpha = 0.3;
MainView.frame = CGRectMake(-160.0f, -40.0f, ScreenSize.size.width, ScreenSize.size.height);
}];
Any thoughts? Thanks a million!

Thank you to #Abizern who suggested it maybe constrained. Turning off constraints works and another way around it was defining the components programatically in the .m

Related

How to Make a Animation in a Bar That Inside the Bar That Moves to the Left While the Actual Loading Bar Moves to the Right

Basically I want to make something similar to this gmail bar http://i.stack.imgur.com/sYWhj.gif.
Right now I am able to make the whole bar and make it progress
These are 3 view properties.
#property (nonatomic, readwrite, strong) UIView *progressBarView;
#property (nonatomic, readwrite, strong) UIImageView *progressBarBackground;
#property (nonatomic, readwrite, strong) UIImageView *progressBar;
and I add progressBarBackground and progressBar as subview in progressBarView.
For bar progress animation I just use
CGRect frame = self.progressBar.frame;
frame.size.width = MAX(kProgressBarMinWidth, kProgressBarWidth * self.progress);
[UIView animateWithDuration:duration
animations:^{
self.progressBar.frame = frame;
}];
But I am having problem adding that left to right animation in the gif. Anyone knows how to do that?
That looks to me to be a pattern-based color fill, and then animating the origin of the pattern. Take a look at the UIColor class method colorwithPatternImage

How to use inputAccessoryViewController in iOS 8

In iOS 8 Apple introduced a new property under UIResponder called inputAccessoryViewController. However there has been no documentation explaining how one can use it.
Moreover, in iOS 8, setting the inputAccessoryView property of a UIViewController subclass and making the subclass the first responder seems to cause the view controller to leak.
My question is: How can I use an inputAccessoryViewController in a UIViewController subclass? Does that solve the memory leak problem?
If you want to use inputAccessoryViewController, you need to subclass any UITextView or UITextField controls and override the inputAccessoryViewController property readwrite.
#interface MyTextView: UITextView
#property (nonatomic, retain) UIInputViewController *inputAccessoryViewController;
#end
Note that the view controller you provide should be a UIInputViewController (which will give you access to input delegate and text document information) and will create the 'inputView' (as self.view) if you call [super loadView], which you can add your subviews to. This UIInputView will be styled appropriately for the keyboard. I haven't experimented with trying to load from .xib in this case.
I also found to properly size the inputView (and avoid a bunch of constraint errors), I added the following code
- (void)updateViewConstraints
{
self.view.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.superview.frame), myAccessoryHeight);
[super updateViewConstraints];
}
Add this method in your code. This will help you. from iOS 7 you need to return UIView only as accessoryView.
-(UIView *)inputAccessoryView{
UIView *accessoryView = [[UIView alloc] initWithFrame:toolView.frame];
toolView.frame = CGRectMake(0, 0, self.view.frame.size.width, 50);
[accessoryView addSubview:toolView];
return accessoryView;
}

UIImageView fade out

In my main storyboard I have a UIViewController with a hidden UIImageView. I read in a thread that to fade an image out I could use the following code. I was wondering how to tie the UIImageView I created with an IBAction.
-(IBAction)popupImage
{
_imageView.hidden = NO;
_imageView.alpha = 1.0f;
// Then fades it away after 2 seconds (the cross-fade animation will take 0.5s)
[UIView animateWithDuration:0.5 delay:2.0 options:0 animations:^{
// Animate the alpha value of your imageView from 1.0 to 0.0 here
_imageView.alpha = 0.0f;
} completion:^(BOOL finished) {
// Once the animation is completed and the alpha has gone to 0.0, hide the view for good
_imageView.hidden = YES;
}];
}
Do I create a #property (strong, nonatomic) IBOutlet UIImageView *imageView; connected to the image?
You're using storyboards, so control-drag the UIImageView into your interface. The property need not be strong--it should read: #property (weak, nonatomic) IBOutlet UIImageView *imageView.
If you don't know how to control-drag, this video may help: https://www.youtube.com/watch?v=xq-a7e_l_4I. Fast-forward to 2:05.
Open the assistant editor
and ctrl-drag form the UIImageView to the top of your file to make an IBOutlet called imageView. You can invoke (call) your method in one of these ways:
If you want to fade the image when someone clicks a button, ctrl-drag from a UIButton to the popupImage method to make an IBAction.
If you want to fade the image programatically, just do [self popupImage] from wherever in your code you want the fade to begin (in viewDidLoad, for example). In this case, you don't need the IBAction part of your method, and can just call it - (void)popupImage.
Since you want to show your image from the beginning, you should not have it set to hidden.

When will a control on a storyboard page be available to get frame info?

I'm using iOS 6 with storyboard and ARC.
I've got on my storyboard a UIView that I want to use for positioning and sizing - I've created an IBOutlet for the control in my controller via the Ctrl drag/drop so I know it's connected.
Now I want to try to reference this UIView from within the controller so I can dynamically create subviews within that UIView, positioned appropriately.
I'm trying to access the UIView from within viewDidLoad as follows
CGRect rect = self.myView.frame;
...but the rect is always coming up as 0, 0, 0, 0. myView is defined in the header file as:
#property (weak, nonatomic) IBOutlet UIView *myView;
I thought that all the controls from the storyboard would already be initialized when you got to viewDidLoad. If this is not the case, where should I put the code to use the frame of the UIView to create my subViews?
Thanks in advance.

why my actual UI layout is not same with my designed layout in xib

this is what I designed in xib, and it's my expectation also.
My ViewControlle.h file:
#interface DetailHeadViewController : UIViewController
#property (weak, nonatomic) IBOutlet UIScrollView *slideScrollView;
#property (weak, nonatomic) IBOutlet UIImageView *smallImageView;
#property (weak, nonatomic) IBOutlet UIImageView *barBGVImageView;
#end
My ViewController.m file (part of the source code)
- (void)viewDidLoad
{
[super viewDidLoad];
slideScrollView.pagingEnabled = YES;
slideScrollView.showsHorizontalScrollIndicator = NO;
slideScrollView.showsVerticalScrollIndicator = NO;
UIImageView * page1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"headSection_hot1"]];
[slideScrollView addSubview:page1]; //Update 3
}
the result is this,
But actually the correct result is this,
Anyone can help to point out what the problem is?
Thanks in advance
update (remove bar image)
for easier, I remove bar image in xib and also comment out the relatived code.
Please see the following picture.
update 2
IB
To me it looks like your scroll view frame is not set correctly. It should probably be set to 0,0,480,320.
It also looks like the transparency isn't set on the BarImageView. Select the BarImageView in the xib, open up the inspector window, click on the 4th tab, set the background color to Clear Color and reduce the alpha.
You may also want to post how your adding the image to the scroll view as that could create issues as well.
Update 1:
In the viewDidLoad of your DetailHeadViewController try this:
self.scrollView.frame = self.view.bounds;
UIImageView * page1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"headSection_hot1"]];
page1.frame = self.view.bounds;
[self.slideScrollView addSubview:page1];
self.scrollView.contentSize = self.view.bounds.size; // Note that the contentSize must be changed
// from this if you want to scroll.

Resources