Quantcast
Channel: Zumbrennen Gyan
Viewing all articles
Browse latest Browse all 10

Switching views according to a device orientation

$
0
0

Q1.Switching views according to a device orientation

 

 

 

I'm perplexing to do this: in my Home's Application, if we put a device in landscape mode I'll arrangement a assistance view. So distant it seems to works morally though if we pull a symbol to go to another view,then we come behind to a Home and put a device in landscape…I see all in a wrong way.

Here are twin images to try to explain a problem:

wrong landscape wrong portrait

Here's my ViewController.m code:

#import "ViewController.h"    @implementation ViewController  @synthesize portraitView, landscapeView;    -  didReceiveMemoryWarning  {  [super didReceiveMemoryWarning];  // Release any cached data, images, etc that aren't in use.  }    #pragma symbol - View lifecycle    -  viewDidLoad  {  [super viewDidLoad];  [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];  [[NSNotificationCenter defaultCenter] addObserver:self        selector:@selector name:@"UIDeviceOrientationDidChangeNotification"     object:nil ];      // Do any additional setup after loading a view, typically from a nib.  }      - orientationChanged: object{  UIDeviceOrientation deviceOrientation = [[object object] orientation];        if    {      self.view = self.portraitView;          }  else if    {      self.view = self.landscapeView;      }  }    -  viewDidUnload  {  [super viewDidUnload];  // Release any defended subviews of a sure view.  // e.g. self.myOutlet = nil;  }    -  viewWillAppear: animated  {  [super viewWillAppear:animated];  }    -  viewDidAppear: animated  {  [super viewDidAppear:animated];  }    -  viewWillDisappear: animated  {  [super viewWillDisappear:animated];  }    -  viewDidDisappear: animated  {  [super viewDidDisappear:animated];  }      -  shouldAutorotateToInterfaceOrientation:      interfaceOrientation  {  // Return YES for upheld orientations  if   {      return  ;  } else {      return YES;  }    }    @end

I wish we can assistance me

 

 

Answer:

 

 

 

You can put additional checks for tide course in viewDidAppear and change views accordingly. You can always get a device's tide course as

[[UIDevice currentDevice] orientation];

EDIT: Try by adding this slight to your class:

- viewDidAppear{  UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];     if     {     self.view = self.portraitView;           }   else if     {   self.view = self.landscapeView;       }  }

EDIT2- Try manually sourroundings course as :

-  viewDidAppear: animated  {    [super viewDidAppear:animated];    UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];      [[UIDevice currentDevice] setOrientation:deviceOrientation];    if       {        self.view = self.portraitView;             }    else if       {        self.view = self.landscapeView;         }  }

 

 

Q2.What's The Error In this code

 

 

 

this formula works glorious in php to beget a tradition scripts generators

 <?php        $arrs = array ;          foreach        {      ?>      <script type="text/javascript" src="<?php relate $var ?>" >  </script>    <?php        }          ?>

this not compiling even whts a probem in my formula a aspx though the not working

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>    <%              IList<string> list;    list = new List<string> ;    foreach    {   %>  <script type="text/javascript" src="<%  lst  %>"   />    <%           }       %>

 

 

Answer:

 

 

 

You blunder is with book line change a line to next solve your one issue..i attempted in my environment

<script type="text/javascript" src="<% =lst %>"   /> 

Full formula will be :

  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>    <%  IList<string> list;        list = new List<string> ;        foreach        {      %>     <script type="text/javascript" src="<% = lst %>"  />       <%           }     %>

 

 

 


Viewing all articles
Browse latest Browse all 10

Trending Articles