Vote count:
0
I am developing a new release of my app and have come across a very frustrating issue. i have some code that repositions a view on the screen after rotation(see below code) When i run it in the simulator there are no issues, when i test on a physical device there is also no issue, until i disconnect from xCode. After disconnecting from Xcode the view no longer re locates correctly. If i reconnect to Xcode and run again it still won't work as it used to/expected. I added the logging you see in the code and now know that on first execution the heigh and with are logging correctly but after disconnect they are reversed. I have also installed an adhoc distribution to a two different devices and again on first execution everything works fine(no Xcode connection this time). But if i completely close the app (double tap home and wipe up) on the next execution we get exactly the same outcome as before with the view repositioning off the screen(presumably the NSlog values will again be reversed). I have searched high and low and can't find any solutions at all.
- (void)deviceOrientationDidChangeNotification:(NSNotification*)note
{
NSLog(@"rotate");
int height = [UIScreen mainScreen].bounds.size.height;
int width = [UIScreen mainScreen].bounds.size.width;
NSLog(@"%@,%d",@"height: ",height);
NSLog(@"%@,%d",@"width: ",width);
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (UIDeviceOrientationIsPortrait(orientation)==YES){
if ([self.vcID.text isEqualToString:@"i4"]) {
self.addheightCont.constant = 50;
}else{
self.addheightCont.constant = 100.0;
}
}else if (UIDeviceOrientationIsLandscape(orientation)==YES){
if ([self.vcID.text isEqualToString:@"i5"]) {
self.addheightCont.constant = 32.0;
}else if ([self.vcID.text isEqualToString:@"i4"]) {
self.addheightCont.constant = 32.0;
}else{
self.addheightCont.constant = 50.0;
}
}
if (height==568) {
self.imageScroller.delegate = self;
self.imageScroller.zoomScale = 0.0;
[self.imageScroller setContentOffset:CGPointMake(0, 0) animated:YES];
self.LargeImage.frame = CGRectMake(0, 0, 320, 568);
self.imageScroller.frame = CGRectMake(0, 0, 320, 568);
self.imageScroller.minimumZoomScale = 1.0;
self.imageScroller.maximumZoomScale = 100.0;
if (self.CommentsView.alpha == 1.0) {
[self.CommentsView setCenter:CGPointMake(160, 284)];
[self.ShowCommentsButton setCenter:CGPointMake(24, 445)];
[self.LikeButtonbutton setCenter:CGPointMake(70.5, 445)];
}
if (self.editCommentView.alpha == 1.0) {
[self.editCommentView setCenter:CGPointMake(160, 284)];
}
}else if (height==480){
self.imageScroller.delegate = self;
self.imageScroller.zoomScale = 0.0;
[self.imageScroller setContentOffset:CGPointMake(0, 0) animated:YES];
self.LargeImage.frame = CGRectMake(0, 0, 320, 480);
self.imageScroller.frame = CGRectMake(0, 0, 320, 480);
self.imageScroller.minimumZoomScale = 1.0;
self.imageScroller.maximumZoomScale = 100.0;
if (self.CommentsView.alpha == 1.0) {
[self.CommentsView setCenter:CGPointMake(160, 240)];
[self.ShowCommentsButton setCenter:CGPointMake(24, 445)];
[self.LikeButtonbutton setCenter:CGPointMake(70.5, 445)];
}
if (self.editCommentView.alpha == 1.0) {
[self.editCommentView setCenter:CGPointMake(160, 284)];
}
}else if ((height==320) && (width==568)){
self.imageScroller.delegate = self;
self.imageScroller.zoomScale = 0.0;
[self.imageScroller setContentOffset:CGPointMake(0, 0) animated:YES];
self.LargeImage.frame = CGRectMake(0, 0, 568, 320);
self.imageScroller.frame = CGRectMake(0, 0, 568, 320);
self.imageScroller.minimumZoomScale = 1.0;
self.imageScroller.maximumZoomScale = 100.0;
if (self.CommentsView.alpha == 1.0) {
[self.CommentsView setCenter:CGPointMake(277, 160)];
[self.ShowCommentsButton setCenter:CGPointMake(24, 304)];
[self.LikeButtonbutton setCenter:CGPointMake(70.5, 304)];
}
if (self.editCommentView.alpha == 1.0) {
[self.editCommentView setCenter:CGPointMake(284, 160)];
}
}else if ((height==320) && (width==480)){
self.imageScroller.delegate = self;
self.imageScroller.zoomScale = 0.0;
[self.imageScroller setContentOffset:CGPointMake(0, 0) animated:YES];
self.LargeImage.frame = CGRectMake(0, 0, 480, 320);
self.imageScroller.frame = CGRectMake(0, 0, 480, 320);
self.imageScroller.minimumZoomScale = 1.0;
self.imageScroller.maximumZoomScale = 100.0;
if (self.CommentsView.alpha == 1.0) {
[self.CommentsView setCenter:CGPointMake(240, 160)];
[self.ShowCommentsButton setCenter:CGPointMake(24, 304)];
[self.LikeButtonbutton setCenter:CGPointMake(70.5, 304)];
}
if (self.editCommentView.alpha == 1.0) {
[self.editCommentView setCenter:CGPointMake(284, 160)];
}
}else if ((height==375) && (width==667)){
self.imageScroller.delegate = self;
self.imageScroller.zoomScale = 0.0;
[self.imageScroller setContentOffset:CGPointMake(0, 0) animated:YES];
self.LargeImage.frame = CGRectMake(0, 0, 667, 375);
self.imageScroller.frame = CGRectMake(0, 0, 667, 375);
self.imageScroller.minimumZoomScale = 1.0;
self.imageScroller.maximumZoomScale = 100.0;
if (self.CommentsView.alpha == 1.0) {
[self.CommentsView setCenter:CGPointMake(333.5, 187.5)];
[self.ShowCommentsButton setCenter:CGPointMake(24, 304)];
[self.LikeButtonbutton setCenter:CGPointMake(70.5, 304)];
}
if (self.editCommentView.alpha == 1.0) {
[self.editCommentView setCenter:CGPointMake(333.5, 115)];
}
}else if (height==667) {
self.imageScroller.delegate = self;
self.imageScroller.zoomScale = 0.0;
[self.imageScroller setContentOffset:CGPointMake(0, 0) animated:YES];
self.LargeImage.frame = CGRectMake(0, 0, 375, 667);
self.imageScroller.frame = CGRectMake(0, 0, 375, 667);
self.imageScroller.minimumZoomScale = 1.0;
self.imageScroller.maximumZoomScale = 100.0;
if (self.CommentsView.alpha == 1.0) {
[self.CommentsView setCenter:CGPointMake(187.5, 333.5)];
[self.ShowCommentsButton setCenter:CGPointMake(24, 445)];
[self.LikeButtonbutton setCenter:CGPointMake(70.5, 445)];
}
if (self.editCommentView.alpha == 1.0) {
[self.editCommentView setCenter:CGPointMake(187.5,115)];
}
}else if (height==736) {
self.imageScroller.delegate = self;
self.imageScroller.zoomScale = 0.0;
[self.imageScroller setContentOffset:CGPointMake(0, 0) animated:YES];
self.LargeImage.frame = CGRectMake(0, 0, 414, 736);
self.imageScroller.frame = CGRectMake(0, 0, 414, 736);
self.imageScroller.minimumZoomScale = 1.0;
self.imageScroller.maximumZoomScale = 100.0;
if (self.CommentsView.alpha == 1.0) {
[self.CommentsView setCenter:CGPointMake(207, 333.5)];
[self.ShowCommentsButton setCenter:CGPointMake(24, 514)];
[self.LikeButtonbutton setCenter:CGPointMake(70.5, 514)];
}
if (self.editCommentView.alpha == 1.0) {
[self.editCommentView setCenter:CGPointMake(207,115)];
}
}else if (height==414){
self.imageScroller.delegate = self;
self.imageScroller.zoomScale = 0.0;
[self.imageScroller setContentOffset:CGPointMake(0, 0) animated:YES];
self.LargeImage.frame = CGRectMake(0, 0, 736, 414);
self.imageScroller.frame = CGRectMake(0, 0, 736, 414);
self.imageScroller.minimumZoomScale = 1.0;
self.imageScroller.maximumZoomScale = 100.0;
if (self.CommentsView.alpha == 1.0) {
[self.CommentsView setCenter:CGPointMake(368, 187.5)];
[self.ShowCommentsButton setCenter:CGPointMake(24, 380)];
[self.LikeButtonbutton setCenter:CGPointMake(70.5, 380)];
}
if (self.editCommentView.alpha == 1.0) {
[self.editCommentView setCenter:CGPointMake(368, 115)];
}
}
}
App behaviour changes after disconnected from xcode
Aucun commentaire:
Enregistrer un commentaire