In Apple iOs photos app, Each picture take the full screen, but when You tap on it, navigation bar and tab bar with some menu options (like share picture) just appear and remain for a couple of secconds. How can I do that in my UIImageView ?
Add a UITapGestureRecognizer to your view and UiView for your topbar and bottom bar or what else you like and follow below code. I think This may help you.
//Write below code in ViewDidLoad
UITapGestureRecognizer *singleTapOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleSingleTap:)];
singleTapOne.numberOfTouchesRequired = 1; singleTapOne.numberOfTapsRequired = 1; singleTapOne.delegate = self;
[self.view addGestureRecognizer:singleTapOne]; [singleTapOne release];
for (UIGestureRecognizer *gR in self.view.gestureRecognizers) {
gR.delegate = self;
// handleSingleTap Method
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer
{
if (recognizer.state == UIGestureRecognizerStateRecognized)
{
CGRect viewRect = recognizer.view.bounds; // View bounds
CGPoint point = [recognizer locationInView:recognizer.view];
CGRect areaRect = CGRectInset(viewRect, TAP_AREA_SIZE, 0.0f); // Area
if (CGRectContainsPoint(areaRect, point)) // Single tap is inside the area
{
if ((m_CtrlViewTopBar.hidden == YES) || (m_CtrlViewBottomBar.hidden == YES))
{
[self showToolbar:m_CtrlViewTopBar];
[self showToolbar:m_CtrlViewBottomBar]; // Show
}
else
{
[self hideToolbar:m_CtrlViewTopBar];
[self hideToolbar:m_CtrlViewBottomBar];
}
return;
}
CGRect nextPageRect = viewRect;
nextPageRect.size.width = TAP_AREA_SIZE;
nextPageRect.origin.x = (viewRect.size.width - TAP_AREA_SIZE);
if (CGRectContainsPoint(nextPageRect, point)) // page++ area
{
//[self incrementPageNumber]; return;
}
CGRect prevPageRect = viewRect;
prevPageRect.size.width = TAP_AREA_SIZE;
if (CGRectContainsPoint(prevPageRect, point)) // page-- area
{
//[self decrementPageNumber]; return;
}
}
}
- (void)hideToolbar:(UIView*)view //Hide Toolbars
{
#ifdef DEBUGX
NSLog(#"%s", __FUNCTION__);
#endif
if (view.hidden == NO)
{
[UIView animateWithDuration:0.25 delay:0.0
options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
animations:^(void)
{
view.alpha = 0.0f;
}
completion:^(BOOL finished)
{
view.hidden = YES;
}
];
}
[timer invalidate];
timer=nil;
}
- (void)showToolbar:(UIView*)view //Show Toolbars
{
#ifdef DEBUGX
NSLog(#"%s", __FUNCTION__);
#endif
if (view.hidden == YES)
{
[UIView animateWithDuration:0.25 delay:0.0
options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
animations:^(void)
{
view.hidden = NO;
view.alpha = 1.0f;
}
completion:NULL
];
if (!timer) {
timer=[NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:#selector(HideToolBarWithTime)
userInfo:nil
repeats:YES];
}
}
[self.view addSubview:view];
}
-(void)HideToolBarWithTime //Hide Toolbars with time
{
[self hideToolbar:m_CtrlViewTopBar];
[self hideToolbar:m_CtrlViewBottomBar];
[timer invalidate];
timer=nil;
}
// Gesture Delegates
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
Related
I have several custom buttons in my view and made them a custom focus animation with didUpdateFocusInContext ,and I added a UITapGestureRecognizer to the view that when user taps twice a method will run ! but the problem is when didUpdateFocusInContext prevents to double tap action until the focused context reaches its end (it means riches to the last button) then method will fire when there is no focusable context !!! how can prevent such thing ? Here is my code :
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator: (UIFocusAnimationCoordinator *)coordinator {
//Setup focausing for main buttons
for (UIButton *mainButton in _nextPrevButton){
if (context.nextFocusedView == mainButton) {
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.40 initialSpringVelocity:.60 options:UIViewAnimationOptionAllowUserInteraction animations:^ {
context.nextFocusedView.transform = CGAffineTransformMakeScale(1.2, 1.2);
context.nextFocusedView.layer.shadowOffset = CGSizeMake(0, 0);
context.nextFocusedView.layer.shadowOpacity = 1;
context.nextFocusedView.layer.shadowRadius = 15;
context.nextFocusedView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
context.nextFocusedView.layer.shadowOpacity = 1;
} completion:nil];
} else {
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.40 initialSpringVelocity:.60 options:UIViewAnimationOptionAllowUserInteraction animations:^ {
context.previouslyFocusedView.transform = CGAffineTransformMakeScale(1, 1);
context.previouslyFocusedView.layer.shadowOpacity = 0;
} completion:nil];
}
}
if (context.nextFocusedView == _button1Focused) { [self buttonFocused:context]; } else if (context.previouslyFocusedView == _button1Focused) { [self buttonNotFocused:context]; }
if (context.nextFocusedView == _button2Focused) { [self buttonFocused:context]; } else if (context.previouslyFocusedView == _button2Focused) { [self buttonNotFocused:context]; }
if (context.nextFocusedView == _button3Focused) { [self buttonFocused:context]; } else if (context.previouslyFocusedView == _button3Focused) { [self buttonNotFocused:context]; }
}
Tapping methods :
- (void)viewDidLoad {
UITapGestureRecognizer *rightTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleRightTap:)];
[rightTap setAllowedPressTypes:#[#(UIPressTypeRightArrow)]];
[rightTap setNumberOfTapsRequired:2];
[self.view addGestureRecognizer:rightTap];
}
- (void)handleRightTap:(UITapGestureRecognizer *)sender {
//or put the code here !
if (sender.state == UIGestureRecognizerStateRecognized)
{
NSLog(#"Right Arrow");
}
}
I tried other states :
if (sender.state == UIGestureRecognizerStateBegan)
{
// handling code
NSLog(#"UIGestureRecognizerStateBegan ");
}
if (sender.state == UIGestureRecognizerStateEnded)
{
// handling code
NSLog(#" UIGestureRecognizerStateEnded ");
}
if (sender.state == UIGestureRecognizerStateRecognized)
{
// handling code
NSLog(#"UIGestureRecognizerStateRecognized");
}
but no success !
How can I do it with out resize view frame (or tableView)?
I use this code and I have resized view then I scroll down/up
I use code, not storyboard
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
if ([gestureRecognizer class] == [UIPanGestureRecognizer class])
{
UIPanGestureRecognizer *panGestureRec = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint distance = [panGestureRec translationInView:self.tableView];
if (distance.y > 0 || distance.y < 0)
{
if (distance.y > 0) // down
{
//NSLog(#"user swiped down");
[self.navigationController setNavigationBarHidden:YES animated:YES];
} else if (distance.y < 0) //up
{
//NSLog(#"user swiped up");
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
return NO;
} else {
return YES;
}
}
return YES;
}
Try this code . This will give smooth animation (Used UIView Animation property)
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
if ([gestureRecognizer class] == [UIPanGestureRecognizer class])
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
UIPanGestureRecognizer *panGestureRec = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint distance = [panGestureRec translationInView:self.tableView];
if (distance.y > 0 || distance.y < 0)
{
if (distance.y > 0) // down
{
//NSLog(#"user swiped down");
[self.navigationController setNavigationBarHidden:YES animated:YES];
} else if (distance.y < 0) //up
{
//NSLog(#"user swiped up");
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
return NO;
} else {
return YES;
}
[UIView commitAnimations];
}
return YES;
I am implementing a custom focus bar on top of my keyboard. The focus bar has widgets to move cursor back and forward along with a done button.
Now, with iOS 7, I am seeing the focus bar is moving faster than keyboard. Because of this for a second I see screen behind the focus bar before it sits on top of keyboard. This is working fine in iOS 6.
Below is what I am doing:
- (void)keyboardWillShow:(NSNotification *)iNotification {
self.dismissForm = NO;
self.shouldScrollCell = YES;
CGFloat aKeyboardAnimationDuration = [[iNotification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
CGRect aKeyboardFrame = [[iNotification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect adjustedKeyboardFrame = [self.view convertRect:aKeyboardFrame fromView:nil];
CGFloat adjustedHeight;
adjustedHeight = aKeyboardFrame.size.height + self.focusControlBar.frame.size.height;
[self.focusControlBar viewForFocusControlWillShowWithEndFrame:adjustedKeyboardFrame andAnimationDuration:aKeyboardAnimationDuration];
[UIView animateWithDuration:0.3 animations:^() {
[self.tableView setContentInset:UIEdgeInsetsMake(kScreenOrigin, kScreenOrigin, adjustedHeight, 0.0f)];
[self.tableView setScrollIndicatorInsets:UIEdgeInsetsMake(kScreenOrigin, kScreenOrigin, adjustedHeight, 0.0f)];
}];
}
This is my focus bar animation code:
- (void)viewForFocusControlWillShowWithEndFrame:(CGRect)iFrame andAnimationDuration:(CGFloat)iDuration {
BOOL aShouldAppear = YES;
if (self.delegate && [self.delegate respondsToSelector:#selector(focusControlBarShouldAppear:)]) {
aShouldAppear = [self.delegate focusControlBarShouldAppear:self];
}
if (aShouldAppear) {
if (self.delegate && [self.delegate respondsToSelector:#selector(focusControlBarWillAppear:)]) {
[self.delegate focusControlBarWillAppear:self];
}
CGRect aBarFrame = self.frame;
UIInterfaceOrientation anInterfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
aBarFrame.size.height = [self heightForOrientation:anInterfaceOrientation];
self.frame = aBarFrame;
aBarFrame.origin.y = self.superview.bounds.size.height - iFrame.size.height - aBarFrame.size.height;
[UIView animateWithDuration:iDuration animations:^(void) {
self.frame = aBarFrame;
} completion:^(BOOL iFinished) {
if (self.delegate && [self.delegate respondsToSelector:#selector(focusControlBarDidAppear:)]) {
[self.delegate focusControlBarDidAppear:self];
}
}];
}
}
I just got to know that with iOS 7 we need to also keep KeyboardAnimationCurve into account. With the below modified code I had it worked.
- (void)keyboardWillShow:(NSNotification *)iNotification {
self.dismissForm = NO;
self.shouldScrollCell = YES;
NSDictionary *aNotificationInfo = [iNotification userInfo];
CGFloat aKeyboardAnimationDuration = [aNotificationInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
UIViewAnimationCurve aKeyboardAnimationCurve = [aNotificationInfo[UIKeyboardAnimationCurveUserInfoKey] intValue];
CGRect aKeyboardFrame = [aNotificationInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect adjustedKeyboardFrame = [self.view convertRect:aKeyboardFrame fromView:nil];
CGFloat adjustedHeight;
adjustedHeight = aKeyboardFrame.size.height + self.focusControlBar.frame.size.height;
[self.focusControlBar viewForFocusControlWillShowWithEndFrame:adjustedKeyboardFrame animationCurve:aKeyboardAnimationCurve andAnimationDuration:aKeyboardAnimationDuration];
[UIView animateWithDuration:0.3 animations:^() {
[self.tableView setContentInset:UIEdgeInsetsMake(kScreenOrigin, kScreenOrigin, adjustedHeight, 0.0f)];
[self.tableView setScrollIndicatorInsets:UIEdgeInsetsMake(kScreenOrigin, kScreenOrigin, adjustedHeight, 0.0f)];
}];
}
- (void)viewForFocusControlWillShowWithEndFrame:(CGRect)iFrame animationCurve:(UIViewAnimationCurve)iAnimationCurve andAnimationDuration:(CGFloat)iDuration {
BOOL aShouldAppear = YES;
if (self.delegate && [self.delegate respondsToSelector:#selector(focusControlBarShouldAppear:)]) {
aShouldAppear = [self.delegate focusControlBarShouldAppear:self];
}
if (aShouldAppear) {
if (self.delegate && [self.delegate respondsToSelector:#selector(focusControlBarWillAppear:)]) {
[self.delegate focusControlBarWillAppear:self];
}
CGRect aBarFrame = self.frame;
UIInterfaceOrientation anInterfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
aBarFrame.size.height = [self heightForOrientation:anInterfaceOrientation];
self.frame = aBarFrame;
aBarFrame.origin.y = self.superview.bounds.size.height - iFrame.size.height - aBarFrame.size.height;
[UIView animateWithDuration:iDuration delay:0.0 options:(iAnimationCurve << 16) animations:^{
self.frame = aBarFrame;
} completion:^(BOOL finished) {
if (self.delegate && [self.delegate respondsToSelector:#selector(focusControlBarDidAppear:)]) {
[self.delegate focusControlBarDidAppear:self];
}
}];
}
}
I have a parent view that allows you to see post in a UITableView. In its Navigation Bar I have a post button that when pressed presents a UIView subclass and shows it on the top of the screen. I have an image on that UIView that when tapped I want to present the UIImagePickerController to allow users to pick an image to post to the service. How can I do this since my subview is not a view controller it cannot present the UIImagePickerController.
Below is my subview code.
#import "PostView.h"
#implementation PostView
#synthesize attachedLabel;
#synthesize postButton;
#synthesize textView;
#synthesize characterLimit;
#synthesize attachImage;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
originalFrame = frame;
NSArray *xib = [[NSBundle mainBundle] loadNibNamed:#"PostView" owner:self options:nil];
PostView *view = [xib objectAtIndex:0];
[view setBackgroundColor:[UIColor whiteColor]];
[view setAlpha:0.7f];
attachedLabel = [[UILabel alloc] initWithFrame:CGRectMake(204, 212, 56, 21)];
attachedLabel.textColor = [UIColor blackColor];
[attachedLabel setText:#"Attached"];
attachedLabel.backgroundColor = [UIColor clearColor];
attachedLabel.font = [UIFont fontWithName:text_font_name size:12.0];
characterLimit = [[UILabel alloc] initWithFrame:CGRectMake(246, 13, 50, 21)];
[characterLimit setTextAlignment:NSTextAlignmentRight];
characterLimit.textColor = [UIColor blackColor];
characterLimit.backgroundColor = [UIColor clearColor];
characterLimit.font = [UIFont fontWithName:text_font_name size:12.0];
attachImage = [[UIImageView alloc] initWithFrame:CGRectMake(270, 208, 30, 30)];
[attachImage setImage:[UIImage imageNamed:#"attachphoto30x30.png"]];
[self.textView setDelegate:self];
[self.textView setAlpha:0.7f];
[self.textView setTextColor:[UIColor whiteColor]];
[self.textView setBackgroundColor:[UIColor clearColor]];
self.layer.cornerRadius = 10.0f;
self.layer.masksToBounds = YES;
[self addSubview:view];
[self addSubview:characterLimit];
[self addSubview:attachedLabel];
[self addSubview:attachImage];
}
return self;
}
- (IBAction)openCamera:(id)sender
{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.delegate = self;
//[self presentViewController:controller animated:YES completion:nil];
NSLog(#"%#", #"Image Tapped");
}
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
/*[picker dismissViewControllerAnimated:YES completion:nil];
UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];
UIImage *scale = [image scaleToSize:CGSizeMake(320.0f, 548.0f)];
imageData = UIImageJPEGRepresentation(scale, 1);
encodedImage = [self Base64Encode:imageData];
[attachedLabel setHidden:NO];
*/
}
#pragma mark Custom alert methods
- (IBAction)postAction:(id)sender
{
[self hide];
}
- (void)show
{
//prepare attachImage
attachImage.userInteractionEnabled = YES;
UITapGestureRecognizer *tapAttach = [[UITapGestureRecognizer alloc]
initWithTarget:self action:#selector(openCamera:)];
tapAttach.numberOfTapsRequired = 1;
[self.attachImage addGestureRecognizer:tapAttach];
isShown = YES;
self.transform = CGAffineTransformMakeScale(0.1, 0.1);
self.alpha = 0;
[UIView beginAnimations:#"showAlert" context:nil];
[self setBackgroundColor:[UIColor clearColor]];
[UIView setAnimationDelegate:self];
self.transform = CGAffineTransformMakeScale(1.1, 1.1);
self.alpha = 1;
[UIView commitAnimations];
}
- (void)hide
{
isShown = NO;
[UIView beginAnimations:#"hideAlert" context:nil];
[UIView setAnimationDelegate:self];
[[NSNotificationCenter defaultCenter] postNotificationName:#"hidePostView_Notification" object:nil];
self.transform = CGAffineTransformMakeScale(0.1, 0.1);
self.alpha = 0;
[UIView commitAnimations];
}
- (void)toggle
{
if (isShown)
{
[self hide];
} else
{
[self show];
}
}
#pragma mark Animation delegate
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
if ([animationID isEqualToString:#"showAlert"])
{
if (finished)
{
[UIView beginAnimations:nil context:nil];
self.transform = CGAffineTransformMakeScale(1.0, 1.0);
[UIView commitAnimations];
}
} else if ([animationID isEqualToString:#"hideAlert"])
{
if (finished)
{
self.transform = CGAffineTransformMakeScale(1.0, 1.0);
self.frame = originalFrame;
}
}
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
return YES;
}
- (BOOL)textView:(UITextView *)textViewer shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)string
{
if ([string isEqualToString:#"\n"])
{
[textViewer resignFirstResponder];
}
return [self isAcceptableTextLength:textViewer.text.length + string.length - range.length];
}
-(IBAction)checkIfCorrectLength:(id)sender
{
if (![self isAcceptableTextLength:self.textView.text.length])
{
// do something to make text shorter
}
}
- (BOOL)isAcceptableTextLength:(NSUInteger)length
{
return length <= 160;
}
- (void)textViewDidChange:(UITextView *)textViewer
{
NSString *characters = [[NSString stringWithFormat:#"%d", textViewer.text.length] stringByAppendingString:#"/160"];
NSLog(#"%#", characters);
[self updateDisplay:characters];
}
-(void) updateDisplay : (NSString *)str
{
[self.characterLimit performSelectorOnMainThread : # selector(setText : ) withObject:str waitUntilDone:YES];
}
#end
Yes, you can not present a viewcontroller from a UIView subclass.
To solve this problem, you can use your subview's superview's viewcontroller class. calling [self.superview nextResponder] in your subview will return you the superview's viewcontroller. Using that you can present your UIImagePicker view controller. To use the presentViewController method, you should cast [self.superview nextResponder] to your parentviewcontroller's class type. Also make sure you import parentview controller.h inside subview.m file
[(YourParentViewController *)[self.superview nextResponder] presentViewController:controller animated:YES completion:nil];
You should present a UIViewController subclass rather than a UIView subclass.
I would also say that UIViewController should be responsible for handling data and operational logic for its views. Check out some of the docs:
View Controller Basics:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html
UIViewController Class Reference:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html
I have a problem with an app that won't set frames outside -init and -viewWillLayoutSubviews methods. What should happen when one taps the editButton is an animation that will hide the editor view. Nonetheless, nothing happens as I test it. The problem doesn't come from the animation method since the -setFrame method as it - not included in the block - doesn't work neither.
Here is the code :
-(id)init {
if (self = [super init]) {
editButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:#selector(editButtonTapped)];
doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(doneButtonTapped)];
editor = [[UIView alloc] init];
[editor setBackgroundColor:[UIColor yellowColor]];
editor.clipsToBounds = YES;
editorIsOpen = YES;
portraitRegularModeEditorRect = CGRectMake(15, 59, 738, 100);
portraitClosedEditorEditorRect = CGRectMake(15, 59, 738, 0);
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[[self view] addSubview:editor];
[[self view] setBackgroundColor:[UIColor blueColor]];
}
-(void)viewDidAppear:(BOOL)animated {
[self setForRegularMode];
}
-(void)viewWillLayoutSubviews {
UIInterfaceOrientation io = [[UIApplication sharedApplication] statusBarOrientation];
if (io == UIInterfaceOrientationPortrait || io == UIInterfaceOrientationPortraitUpsideDown) {
//portrait
[editor setFrame:portraitRegularModeEditorRect];
} else {
//landscape
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(void)editButtonTapped {
[self setForScenarioLinesEditingMode];
}
-(void)doneButtonTapped {
[self setForRegularMode];
}
-(void)setForRegularMode {
editingMode = CPRegularMode;
if (!editorIsOpen) {
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationCurveEaseOut animations:^(void){
[editor setFrame:portraitRegularModeEditorRect];
} completion:^(BOOL finished) {
editorIsOpen = YES;
}];
}
[[self navigationItem] setRightBarButtonItems:[[NSArray alloc] initWithObjects:editButton,nil]];
}
-(void)setForScenarioLinesEditingMode {
editingMode = CPScenarioLinesEditingMode;
if (editorIsOpen) {
[UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationCurveEaseOut animations:^(void){
[editor setFrame:portraitClosedEditorEditorRect];
} completion:^(BOOL finished) {
editorIsOpen = NO;
}];
}
[[self navigationItem] setRightBarButtonItems:[[NSArray alloc] initWithObjects:doneButton,nil]];
}
If anyone can help, thanks in advance ;)
I think that the problem in your case is the fact that in -(void)viewWillLayoutSubviews method you set, lets say the default frame of your view, if you try to change the frame in other methods after the setFrame is called on your view, the -(void)viewWillLayoutSubviews will also be called and the frame of the view will be the default one. Try to remove the setFrame from your -(void)viewWillLayoutSubviews.
Is your view controller set up in storyboards, and are you using Autolayout (which is on by default?) If so, setFrame won't work and you need to edit constraints after creating outlets to them from the storyboard.
Alternatively, you can turn off Autolayout in your storyboard, as shown here.